www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Link problem with Derelict3

reply "moechofe" <truc moechofe.com> writes:
Hi,

I have a problem when I try to compile Derelict3 under linux. I 
try different orders of the linked libraries without success.

I've got this error:

/home/martin/Derelict3/lib/dmd/libDerelictSDL2.a(sdl_106_698.o):(.rodata+0x3094):
référence indéfinie vers « 
_D6object6Object8opEqualsMFC6ObjectC6ObjectZb »
collect2: erreur: ld a retourné 1 code d'état d'exécution

I'm using "pragma" instructions but it's the same with passing 
the "-L-l" argument to "dmd":

Here is my little source file:

module main;

import std.stdio;
import derelict.sdl2.sdl;

pragma(lib,"dl");
pragma(lib,"DerelictSDL2");
pragma(lib,"DerelictUtil");

void main()
{
   DerelictSDL2.load();
   SDL_Init(SDL_INIT_EVERYTHING);
   SDL_Quit();
}

Here is the command line extracted using the --verbose argument, 
that produce the error:

gcc main.o -o main -m32 -L/home/martin/Derelict3/lib/dmd 
-L/usr/lib/i386-linux-gnu -L/usr/lib/x86_64-linux-gnu -Xlinker
--no-warn-search-mismatch -Xlinker --export-dynamic
-lDerelictSDL2 -lDerelictUtil -ldl -l:libphobos2.a -lpthread -lm 
-lrt

I got the official ubuntu package from the dlang.org and try on 4 
differents computer. It only works on Windows.

How I can solve this, please?
Jul 22 2013
parent reply Justin Whear <justin economicmodeling.com> writes:
On Mon, 22 Jul 2013 20:07:28 +0200, moechofe wrote:

 Hi,
 
 I have a problem when I try to compile Derelict3 under linux. I try
 different orders of the linked libraries without success.
 
 I've got this error:
 
 /home/martin/Derelict3/lib/dmd/libDerelictSDL2.a(sdl_106_698.o):(.rodata
+0x3094):
 référence indéfinie vers «
 _D6object6Object8opEqualsMFC6ObjectC6ObjectZb »
 collect2: erreur: ld a retourné 1 code d'état d'exécution
 
 I'm using "pragma" instructions but it's the same with passing the
 "-L-l" argument to "dmd":
 
 Here is my little source file:
 
 module main;
 
 import std.stdio;
 import derelict.sdl2.sdl;
 
 pragma(lib,"dl");
 pragma(lib,"DerelictSDL2");
 pragma(lib,"DerelictUtil");
 
You should link dependencies _after_ the library which depends on them. In particular, your pragmas should go in this order: pragma(lib,"DerelictSDL2"); pragma(lib,"DerelictUtil"); pragma(lib,"dl"); That said, your error looks like a problem between DerelictSDL and phobos; make sure the derelict libraries have been compiled with the same compiler version that you're trying to use.
Jul 22 2013
parent <truc moechofe.com> writes:
Justin Whear <justin economicmodeling.com> wrote:
 On Mon, 22 Jul 2013 20:07:28 +0200, moechofe wrote:
 
 Hi,
 
 I have a problem when I try to compile Derelict3 under linux. I try
 different orders of the linked libraries without success.
 
 I've got this error:
 
 /home/martin/Derelict3/lib/dmd/libDerelictSDL2.a(sdl_106_698.o):(.rodata
+0x3094):
 référence indéfinie vers «
 _D6object6Object8opEqualsMFC6ObjectC6ObjectZb »
 collect2: erreur: ld a retourné 1 code d'état d'exécution
 
 I'm using "pragma" instructions but it's the same with passing the
 "-L-l" argument to "dmd":
 
 Here is my little source file:
 
 module main;
 
 import std.stdio;
 import derelict.sdl2.sdl;
 
 pragma(lib,"dl");
 pragma(lib,"DerelictSDL2");
 pragma(lib,"DerelictUtil");
 
You should link dependencies _after_ the library which depends on them. In particular, your pragmas should go in this order: pragma(lib,"DerelictSDL2"); pragma(lib,"DerelictUtil"); pragma(lib,"dl"); That said, your error looks like a problem between DerelictSDL and phobos; make sure the derelict libraries have been compiled with the same compiler version that you're trying to use.
Thanx, It works by putting "dl" at the end.
Jul 22 2013