User forums > Using Code::Blocks

[SOLVED] Using a DLL

<< < (2/4) > >>

TheLastArrived:

--- Quote from: thomas on May 13, 2008, 12:38:27 pm ---
--- Quote ---It seems that the dll is built (and to be used) with MS VC++ (i'm using MinGW compiler) so I'm trying using pexports
--- End quote ---
That works, but shouldn't even be necessary. I always link to MSVC DLLs directly, works every time.

--- End quote ---

well, it's quite an old DLLs maybe that's the problem


--- Quote from: thomas on May 13, 2008, 12:38:27 pm ---
--- Quote ---Linking executable: bin\Debug\DBXProva02.exe
D:\Programmi\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lDbx32.dll
--- End quote ---
It can't find the library. Try giving it an absolute path (or project root relative), if nothing else helps.

--- End quote ---

If I give an absolute path, C::B finds the lib but the undefined reference problem returns

--- Code: ----------------- Build: Debug in DBXProva02 ---------------

Linking executable: bin\Debug\DBXProva02.exe
obj\Debug\DBXProva02Main.o: In function `ZN15DBXProva02Frame9OnNewFileER20wxFileDirPickerEvent':
D:/Sources/SCE/DBX Utilities/DBXProva02/DBXProva02Main.cpp:81: undefined reference to `_Z11TOpenDesignllPKcP10DbxContext@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings
--- End code ---

Same problem if I link the import library (lib<name>.a) made with dlltool  or even if I link both the DLL and the .a :(
Missing function TOpenDesign is defined in header file as
--- Code: ---long __stdcall TOpenDesign(/* args list*/);
--- End code ---
so I've tried dlltool with and without -U switch

TheLastArrived:

--- Quote from: MortenMacFly on May 13, 2008, 02:17:12 pm ---Enabling the full compiler log might help (see my sig).This may give you some more hints, e.g. a missing / wrong include path for the linker (not the compiler!).

--- End quote ---

Right, here you are
Dbx32.dll only linked:

--- Code: ----------------- Build: Debug in DBXProva02 ---------------

mingw32-g++.exe -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE  -g -D__WXDEBUG__    -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\contrib\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud  -c "D:\Sources\SCE\DBX Utilities\DBXProva02\DBXProva02Main.cpp" -o obj\Debug\DBXProva02Main.o
mingw32-g++.exe -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE  -g -D__WXDEBUG__    -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\contrib\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud  -c "D:\Sources\SCE\DBX Utilities\DBXProva02\GUIFrame.cpp" -o obj\Debug\GUIFrame.o
windres.exe -i D:\Sources\SCE\DBXUTI~1\DBXPRO~1\resource.rc -J rc -o obj\Debug\resource.res -O coff -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud
mingw32-g++.exe -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE  -g -D__WXDEBUG__    -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\contrib\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud  -c "D:\Sources\SCE\DBX Utilities\DBXProva02\DBXProva02App.cpp" -o obj\Debug\DBXProva02App.o
mingw32-g++.exe -LD:\Programmi\wxWidgets2.8\lib\gcc_dll  -o bin\Debug\DBXProva02.exe obj\Debug\DBXProva02Main.o obj\Debug\GUIFrame.o obj\Debug\DBXProva02App.o  obj\Debug\resource.res   -lwxmsw28ud "D:\Sources\SCE\DBX Utilities\DBXProva02\Dbx32.dll"  -mwindows
obj\Debug\DBXProva02Main.o: In function `ZN15DBXProva02Frame9OnNewFileER20wxFileDirPickerEvent':
D:/Sources/SCE/DBX Utilities/DBXProva02/DBXProva02Main.cpp:81: undefined reference to `_Z11TOpenDesignllPKcP10DbxContext@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 24 seconds)
1 errors, 0 warnings
--- End code ---

with libDbx32.a (-U switch) only linked:

--- Code: ----------------- Build: Debug in DBXProva02 ---------------

mingw32-g++.exe -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE  -g -D__WXDEBUG__    -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\contrib\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud  -c "D:\Sources\SCE\DBX Utilities\DBXProva02\DBXProva02Main.cpp" -o obj\Debug\DBXProva02Main.o
mingw32-g++.exe -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE  -g -D__WXDEBUG__    -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\contrib\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud  -c "D:\Sources\SCE\DBX Utilities\DBXProva02\GUIFrame.cpp" -o obj\Debug\GUIFrame.o
windres.exe -i D:\Sources\SCE\DBXUTI~1\DBXPRO~1\resource.rc -J rc -o obj\Debug\resource.res -O coff -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud
mingw32-g++.exe -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE  -g -D__WXDEBUG__    -ID:\Programmi\wxWidgets2.8\include -ID:\Programmi\wxWidgets2.8\contrib\include -ID:\Programmi\wxWidgets2.8\lib\gcc_dll\mswud  -c "D:\Sources\SCE\DBX Utilities\DBXProva02\DBXProva02App.cpp" -o obj\Debug\DBXProva02App.o
mingw32-g++.exe -LD:\Programmi\wxWidgets2.8\lib\gcc_dll  -o bin\Debug\DBXProva02.exe obj\Debug\DBXProva02Main.o obj\Debug\GUIFrame.o obj\Debug\DBXProva02App.o  obj\Debug\resource.res   -lwxmsw28ud "D:\Sources\SCE\DBX Utilities\DBXProva02\libDbx32.a"  -mwindows
obj\Debug\DBXProva02Main.o: In function `ZN15DBXProva02Frame9OnNewFileER20wxFileDirPickerEvent':
D:/Sources/SCE/DBX Utilities/DBXProva02/DBXProva02Main.cpp:81: undefined reference to `_Z11TOpenDesignllPKcP10DbxContext@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 20 seconds)
1 errors, 0 warnings

--- End code ---

thomas:

--- Quote from: TheLastArrived on May 13, 2008, 02:31:39 pm ---If I give an absolute path, C::B finds the lib but the undefined reference problem returns
--- End quote ---
Having it find the DLL at all is half of it already. Now, if it still misses a symbol, there are two possibilities left:
1. the symbol isn't in the DLL at all (wrong DLL)... duh :)
2. C++ name mangling. Either the DLL or your program (most likely your program) mangles names, and the respective other does not. Therefore the names aren't the same, and the linker doesn't find the symbol.
Solution: play with extern "C"

stahta01:

--- Quote from: thomas on May 13, 2008, 08:33:55 pm ---Solution: play with extern "C"

--- End quote ---

But, he does not have the source. So, playing with extern "C" would be hard to use.

Edit: But, I just realized he most likely have a header that might need edited by added extern "C".

Tim S

stahta01:
Do you have the header called Dbx32.h

What does the signature of the function TOpenDesign or whatever the function having linking problem look like.

I Goggled the below.


--- Code: ---long
DLLX TOpenDesign (long language,
                  long version,
                  const char* pDesignName,
                  DbxContext* pContext);

--- End code ---

If yes, the DLLX needs defined as something, but I am not sure what in your case.

Tim S

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version