digitalmars.D.bugs - Fishy Linker Behavior
- James Dunne (61/61) Apr 25 2005 [NOTE: I had posted this on the digitalmars.D NG a while ago with no res...
- Thomas Kuehne (12/71) Apr 25 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Nick (8/12) Apr 26 2005 How does the resulting gcc line look? (the one that dmd produces and dum...
[NOTE: I had posted this on the digitalmars.D NG a while ago with no response. Hopefully on digitalmars.D.bugs someone might take interest. I probably should've originally posted here] This is certainly an interesting one... This has been jabbing me in the sides now for the last couple hours. I have a simple client program that wants to use Derelict's SDL bindings (check out www.dsource.org). I have the Derelict libraries compiled correctly with no warnings/errors on Linux and stored in the library search path. Obviously, they are linked in statically. ----------------------------- module udpclient; import derelict.sdl.sdl; import derelict.sdl.net; int main(char[][] args) { // Load SDL's DLLs DerelictSDL_Load(); DerelictSDLNet_Load(); return 0; } ---------------------------- Now, my build line looks like this: dmd udpclient.d -L-lsqlite3 -L-lderelictSDL -L-lderelictUtil -L-lderelictSDLNet -L-ldl However, the linker gives me strange errors when I try to link: (output summarized) undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_d_assert' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' Obviously the phobos library is linked in, so that doesn't make sense. The real kicker is when I make this tiny change to the udpclient.d source: ----------------------------------- int main(char[][] args) { // This new dummy assert added... assert( 1 == 1 ); // Load SDL's DLLs ----------------------------------- After that, gcc's linker output is reduced to this: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' Notice the magical disappearance of undefined reference: `_d_assert' ? Now, I add this dummy class definition to my udpclient.d source code: class DummyClass { void somefunc() in { assert ( 1 == 1 ); } out { assert ( 1 > 0 ); } body { printf("hi\n"); } } All my linker errors disappear and the code correctly compiles! Fishy things going on here!! Is this a problem with GCC or DMD? I'm using version 0.120 of DMD and GCC 3.3.5. If any more information is required to debug this problem, let me know and I'll be glad to assist. Regards, James Dunne
Apr 25 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 James Dunne schrieb am Mon, 25 Apr 2005 19:20:12 +0000 (UTC):[NOTE: I had posted this on the digitalmars.D NG a while ago with no response. Hopefully on digitalmars.D.bugs someone might take interest. I probably should've originally posted here] This is certainly an interesting one... This has been jabbing me in the sides now for the last couple hours. I have a simple client program that wants to use Derelict's SDL bindings (check out www.dsource.org). I have the Derelict libraries compiled correctly with no warnings/errors on Linux and stored in the library search path. Obviously, they are linked in statically. ----------------------------- module udpclient; import derelict.sdl.sdl; import derelict.sdl.net; int main(char[][] args) { // Load SDL's DLLs DerelictSDL_Load(); DerelictSDLNet_Load(); return 0; } ---------------------------- Now, my build line looks like this: dmd udpclient.d -L-lsqlite3 -L-lderelictSDL -L-lderelictUtil -L-lderelictSDLNet -L-ldl However, the linker gives me strange errors when I try to link: (output summarized) undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_d_assert' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' Obviously the phobos library is linked in, so that doesn't make sense. The real kicker is when I make this tiny change to the udpclient.d source: ----------------------------------- int main(char[][] args) { // This new dummy assert added... assert( 1 == 1 ); // Load SDL's DLLs ----------------------------------- After that, gcc's linker output is reduced to this: undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' undefined reference to `_D9invariant12_d_invariantFC6ObjectZv' Notice the magical disappearance of undefined reference: `_d_assert' ? Now, I add this dummy class definition to my udpclient.d source code: class DummyClass { void somefunc() in { assert ( 1 == 1 ); } out { assert ( 1 > 0 ); } body { printf("hi\n"); } } All my linker errors disappear and the code correctly compiles! Fishy things going on here!! Is this a problem with GCC or DMD? I'm using version 0.120 of DMD and GCC 3.3.5. If any more information is required to debug this problem, let me know and I'll be glad to assist.Do you have GDC's libphobos in your path? Did you at some point rebuild DMD's libphobos? Does your libphobos.a contain invariant.o and asserterror.o? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCbait3w+/yD4P9tIRAt/2AKCx2JtYdTpR0FLkLwsp1RupcJqJ+ACfeapo 4CbkdR66LcPGUOt+oy/W5n0= =buEH -----END PGP SIGNATURE-----
Apr 25 2005
In article <d4jftc$2hu9$1 digitaldaemon.com>, James Dunne says...Now, my build line looks like this: dmd udpclient.d -L-lsqlite3 -L-lderelictSDL -L-lderelictUtil -L-lderelictSDLNet -L-ldlHow does the resulting gcc line look? (the one that dmd produces and dumps to screen before executing)Obviously the phobos library is linked in, so that doesn't make sense.This MIGHT be the same issue I have bumped into earlier. The gcc linker is picky about the order of its parameters. Since depends on phobos, phobos must be specified _after_ derelict on the command line. Just try adding -L-lphobos at the end of the command and see if it works. Nick
Apr 26 2005