D.gnu - Strange linker problems
- Benjamin Thaut (46/46) Mar 18 2013 I have a strange problem with gdc. The linker reports undefined
- Johannes Pfau (8/63) Mar 18 2013 Could it be this:
- Benjamin Thaut (13/19) Mar 18 2013 So this is a bug in gdc? Shouldn't gdc always pass the object files to
I have a strange problem with gdc. The linker reports undefined references to symbols, but exactly those symbols exist in the library that I'm linking into the executable. The error message I get is: C:\Users\Benjamin\AppData\Local\Temp\cc4pUOfp.o:main.d:(.text+0x3a): undefined reference to `_D6thBase2io8writeflnFAyaYm' But: nm libthBase64d_mingw.a | grep writefln 000000000003c9b2 T _D6thBase2io8writeflnFAyaYm I'm building with: gdc -m64 -I"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\.. ..\druntime\import" -I"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos" -I"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\thBase\src" -fversion=NOGCSAFE -o "test.exe" -L"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos" -L. -lthBase64d_mingw -debuglib=phobosnogc64d_mingw -Wl,--verbose=2 -defaultlib=phobosnogc64d_mingw -v -pipe -nostdinc main.d The verbose output of the linker also shows that it finds the correct library file: attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/libt Base64d_mingw.dll.a failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/t Base64d_mingw.dll.a failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/ ibthBase64d_mingw.a failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos thBase64d_mingw.lib failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/li thBase64d_mingw.dll failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos thBase64d_mingw.dll failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos\ ibthBase64d_mingw.a failed attempt to open ./libthBase64d_mingw.dll.a failed attempt to open ./thBase64d_mingw.dll.a failed attempt to open ./libthBase64d_mingw.a succeeded Any ideas what is going wrong here? Kind Regards Benjamin Thaut
Mar 18 2013
Am Mon, 18 Mar 2013 08:07:43 +0100 schrieb Benjamin Thaut <code benjamin-thaut.de>:I have a strange problem with gdc. The linker reports undefined references to symbols, but exactly those symbols exist in the library that I'm linking into the executable. The error message I get is: C:\Users\Benjamin\AppData\Local\Temp\cc4pUOfp.o:main.d:(.text+0x3a): undefined reference to `_D6thBase2io8writeflnFAyaYm' But: nm libthBase64d_mingw.a | grep writefln 000000000003c9b2 T _D6thBase2io8writeflnFAyaYm I'm building with: gdc -m64 -I"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\.. ..\druntime\import" -I"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos" -I"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\ga e\..\..\thBase\src" -fversion=NOGCSAFE -o "test.exe" -L"C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos" -L. -lthBase64d_mingw -debuglib=phobosnogc64d_mingw -Wl,--verbose=2 -defaultlib=phobosnogc64d_mingw -v -pipe -nostdinc main.d The verbose output of the linker also shows that it finds the correct library file: attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/libt Base64d_mingw.dll.a failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/t Base64d_mingw.dll.a failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/ ibthBase64d_mingw.a failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos thBase64d_mingw.lib failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/li thBase64d_mingw.dll failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos thBase64d_mingw.dll failed attempt to open C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos\ ibthBase64d_mingw.a failed attempt to open ./libthBase64d_mingw.dll.a failed attempt to open ./thBase64d_mingw.dll.a failed attempt to open ./libthBase64d_mingw.a succeeded Any ideas what is going wrong here? Kind Regards Benjamin ThautCould it be this: http://stackoverflow.com/questions/8640642/gcc-link-order-changed Something changed in ld some time ago and the order in which libraries are passed to ld is now important. The library which defines _D6thBase2io8writeflnFAyaYm must be passed to ld first, the lib/object file using it second.
Mar 18 2013
Am 18.03.2013 09:51, schrieb Johannes Pfau:Could it be this: http://stackoverflow.com/questions/8640642/gcc-link-order-changed Something changed in ld some time ago and the order in which libraries are passed to ld is now important. The library which defines _D6thBase2io8writeflnFAyaYm must be passed to ld first, the lib/object file using it second.So this is a bug in gdc? Shouldn't gdc always pass the object files to the linker first? I noticed that if I change the build command to gdc -m64 -g -fno-inline-functions -fdebug -I"C:\Users\Benjamin\Documents\d-projects\thBase\src\..\..\druntime\import" -I"C:\Users\Benjamin\Documents\d-projects\thBase\src\..\..\phobos" -fversion=NOGCSAFE -fversion=MEMORY_TRACKING -fdeps="Debug Lib GDC\thBase.dep" -nostdinc -O0 -c -o "Debug Lib GDC\thBase.obj" "Debug Lib GDC\thBase.build.rsp" It works correctly. Thanks for the tip. Kind Regards Benjamin Thaut
Mar 18 2013