Hello all,
I don't know if this is the right place so I apologize if it's not.
I've to write an application that uses function from a dll but when I try to build a
undefined reference to `_Z11TOpenDesignllPKcP10DbxContext@16'|
error message appears.
I've tried to tell C::B where to find the function but without success.
Any hints?
Thank you for helping.
Let's try to be less vague.
I've to write an interface to a program, the program vendor gives a DLL and a header file to develop interface applications (too bad the vendor is no more accessible so no support available).
I create a std new wxWidget program, I include the header file then I use a function of the DLL (TOpenDesign) in event handler and I get
-------------- 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, 0 seconds)
1 errors, 0 warnings
Quite right, there is no reference to libraries, so I add the dll to "link libraries" list, retry building an get
Linking executable: bin\Debug\DBXProva02.exe
D:\Programmi\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lDbx32.dll
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
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, dlltool and other tool to create an import library but I got no success yet.
There is something I'm missing?
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
That works, but shouldn't even be necessary. I always link to MSVC DLLs directly, works every time.
well, it's quite an old DLLs maybe that's the problem
Linking executable: bin\Debug\DBXProva02.exe
D:\Programmi\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lDbx32.dll
It can't find the library. Try giving it an absolute path (or project root relative), if nothing else helps.
If I give an absolute path, C::B finds the lib but the undefined reference problem returns
-------------- 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
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 aslong __stdcall TOpenDesign(/* args list*/);
so I've tried dlltool with and without -U switch
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!).
Right, here you are
Dbx32.dll only linked:
-------------- 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
with libDbx32.a (-U switch) only linked:
-------------- 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
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.
long
DLLX TOpenDesign (long language,
long version,
const char* pDesignName,
DbxContext* pContext);
If yes, the DLLX needs defined as something, but I am not sure what in your case.
Tim S
Update
@stahta01: DLLX is defined as __stdcall
extern "C": in Dbx32.h added
#ifdef __cplusplus
extern "C"
{
#endif
.......
#ifdef __cplusplus
}
#endif
now if I try to build I get
-------------- 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 `TOpenDesign@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
The prefixed underscores disappeared and the name more readable but the function is still missing. :(
I tried with all possible combinations of .dll, .lib, lib<>.a w and w/o -U switch in dlltool. No way.
It's not likely I'm using wrong DLL, because it's part of a package with the header file, given with a CD by the vendor.
Bingo :D
edit: I'm wrong don't do it... see some posts below
I've replace
with
in DBx32.h and now I get a beautiful
Process terminated with status 0 (0 minutes, 26 seconds)
0 errors, 0 warnings
I hope it'll functions correctly :wink: