Strange linker problems
Johannes Pfau
nospam at example.com
Mon Mar 18 01:51:35 PDT 2013
Am Mon, 18 Mar 2013 08:07:43 +0100
schrieb Benjamin Thaut <code at 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\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/libthBase64d_mingw.dll.a
> failed
> attempt to open
> C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/thBase64d_mingw.dll.a
> failed
> attempt to open
> C:\Users\Benjamin\Documents\d-projects\Spacecraft-git\game\..\..\phobos/libthBase64d_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/libthBase64d_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\libthBase64d_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
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.
More information about the D.gnu
mailing list