Page 1 of 1

Problem compiling Dynamic C++ Libray

Posted: Sat Jul 04, 2015 2:45 pm
by Dechcaudron
Hi there guys,

just installed CL. Looks great and way better than C::B. However, I just started creating a Dynamic C++ Library (it barely has 2 classes so far), but cannot get it to compile. The following log is issued:

/bin/sh -c '/usr/bin/make -j8 -e -f Makefile'
----------Building project:[ InsomniaEngine - Debug ]----------
make[1]: Entering directory '/home/dccdn/Repositories/InsomniaEngine/InsomniaEngine'
/usr/bin/g++ -c "/home/dccdn/Repositories/InsomniaEngine/InsomniaEngine/Node.cpp" -g -o ./Debug/Node.cpp.o -I. -I.
/usr/bin/g++ -c "/home/dccdn/Repositories/InsomniaEngine/InsomniaEngine/Stage.cpp" -g -o ./Debug/Stage.cpp.o -I. -I.
/usr/bin/g++ -shared -fPIC -o ./Debug/InsomniaEngine.so @"InsomniaEngine.txt" -L.
/usr/bin/ld: ./Debug/Stage.cpp.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
./Debug/Stage.cpp.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
InsomniaEngine.mk:76: recipe for target 'Debug/InsomniaEngine.so' failed
make[1]: *** [Debug/InsomniaEngine.so] Error 1
make[1]: Leaving directory '/home/dccdn/Repositories/InsomniaEngine/InsomniaEngine'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
1 errors, 0 warnings

I can't really find where I've gone wrong if I have, but I'm guessing it has something to do with the line:

/usr/bin/ld: ./Debug/Stage.cpp.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC

Can anyone help me out on how to solve this problem?

Thanks a lot beforehand :D

Re: Problem compiling Dynamic C++ Libray

Posted: Sat Jul 04, 2015 5:02 pm
by DavidGH
Hi,
I'm guessing it has something to do with the line:
/usr/bin/ld: ./Debug/Stage.cpp.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
I'm sure you're right, at least for a 64bit build.

Did you try adding -fPIC to the Project Settings > Linker field?

Regards,

David

Re: Problem compiling Dynamic C++ Libray

Posted: Sat Jul 04, 2015 5:57 pm
by eranif
DavidGH wrote:Did you try adding -fPIC to the Project Settings > Linker field?
This won't help. He needs to recompile the sources with -fPIC, i.e. put it in the "Project Settings->Compiler->C++ compiler options" field

Eran

Re: Problem compiling Dynamic C++ Libray

Posted: Sun Jul 05, 2015 2:13 am
by Dechcaudron
This won't help. He needs to recompile the sources with -fPIC, i.e. put it in the "Project Settings->Compiler->C++ compiler options" field
Damn, it worked. Thanks a lot guys. Looks like I'm gonna love this IDE.

Best regards,
Dechcaudron