Menu

dll linking trouble

2004-06-16
2012-09-26
  • Nobody/Anonymous

    hi there

    I got a little problem using the UnRAR.dll

    I tried to compile the sample code published with the dll, but I got many linker errors.

    ************************************************
    Compiler: Default compiler
    Building Makefile: "C:\ursin\data\C_C++\UnRARDLL\Example\C\Makefile.win"
    Fhrt  make clean aus
    rm -f UnRDLL.o UnRAR_private.res UnRAR.exe

    g++.exe -c UnRDLL.c -o UnRDLL.o -I"C:/Dev-Cpp/include/c++"  -I"C:/Dev-Cpp/include/c++/mingw32"  -I"C:/Dev-Cpp/include/c++/backward"  -I"C:/Dev-Cpp/include" 

    windres.exe -i UnRAR_private.rc -I rc -o UnRAR_private.res -O coff

    g++.exe UnRDLL.o UnRAR_private.res -o "UnRAR.exe" -L"C:/Dev-Cpp/lib" unrar.lib

    UnRDLL.o(.text+0x174):UnRDLL.c: undefined reference to `RAROpenArchiveEx@4'
    UnRDLL.o(.text+0x1df):UnRDLL.c: undefined reference to `RARSetCallback@12'
    UnRDLL.o(.text+0x1fe):UnRDLL.c: undefined reference to `RARReadHeader@8'
    UnRDLL.o(.text+0x2c6):UnRDLL.c: undefined reference to `RARProcessFile@16'
    UnRDLL.o(.text+0x313):UnRDLL.c: undefined reference to `RARCloseArchive@4'
    UnRDLL.o(.text+0x3eb):UnRDLL.c: undefined reference to `RAROpenArchiveEx@4'
    UnRDLL.o(.text+0x454):UnRDLL.c: undefined reference to `RARSetCallback@12'
    UnRDLL.o(.text+0x49f):UnRDLL.c: undefined reference to `RARReadHeaderEx@8'

    UnRDLL.o(.text+0x52b):UnRDLL.c: undefined reference to `RARProcessFile@16'
    UnRDLL.o(.text+0x567):UnRDLL.c: undefined reference to `RARCloseArchive@4'

    make.exe: *** [UnRAR.exe] Error 1

    Ausfhrung beendet
    ************************************************

    As you can see I linked the "unrar.lib" file to my project, so I DON'T UNDERSTAND WHY THIS WON'T
    WORK!

    CAN YOU HELP ME???

    thank to you, guys!! ;)

     
    • Liviu Nicolescu

      Liviu Nicolescu - 2004-06-16

      The lib file provided with unrardll package is not compatible with gcc.

      In order to create an import lib compatible with gcc, one should do the following steps:

      1-download the pexports tool from http://mywebpage.netscape.com/yongweiwu/stdcall.htm

      2-unzip pexports-0.43.zip and copy pexports.exe in a directory that is in the PATH

      3-open a command prompt window and cd to the directory where unrar.dll is located

      4-type "pexports unrar.dll >unrar.def"

      5- open unrar.def in a text editor and modify it like this:
      LIBRARY unrar.dll
      EXPORTS
      RARCloseArchive@4
      RARGetDllVersion@0
      RAROpenArchive@4
      RAROpenArchiveEx@4
      RARProcessFile@16
      RARProcessFileW@16
      RARReadHeader@8
      RARReadHeaderEx@8
      RARSetCallback@12
      RARSetChangeVolProc@8
      RARSetPassword@8
      RARSetProcessDataProc@8
      ___CPPdebugHook DATA

      6-run "dlltool -d unrar.def --dllname unrar.dll --output-lib libunrar.a --kill-at" in the command prompt window

      7-add libunrar.a at your linker settings and recompile your project

      Good luck

      Liviu

       
    • Nobody/Anonymous

      You can't use a .lib as an import library.  It has to be converted to a .a libaray.  Information at the following link.

      http://lair.gamedeveloper.net/all/entityview.php?eid=641

      Also to link a library you need to use -l before the library name. i.e. -lunrar

       
    • Liviu Nicolescu

      Liviu Nicolescu - 2004-06-16

      Yes, I forgot about reimp ;)

      "reimp unrar.lib" will create the import library.

      You can find both reimp and pexports binaries in the mingw-utils-0.2.tar.gz package from mingw.org.

      Liviu

       
    • Nobody/Anonymous

      THANK YOU VERY VERY MUCH GUYS!!!

      THAT WAS THE BEST AND MOST FAST POSTING I EVER SAW! MY PROBLEM IS SOLVED! I'M NEAR TO SAY "I LOVE YOU ALL" !! :)

      thanks to you

      ps:"liviu" did you used the "unrar.dll" too??

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.