Problem compiling Dynamic C++ Libray

General questions regarding the usage of CodeLite
Dechcaudron
CodeLite Curious
Posts: 2
Joined: Sat Jul 04, 2015 2:41 pm
Genuine User: Yes
IDE Question: C++
Contact:

Problem compiling Dynamic C++ Libray

Post 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
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Problem compiling Dynamic C++ Libray

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem compiling Dynamic C++ Libray

Post 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
Make sure you have read the HOW TO POST thread
Dechcaudron
CodeLite Curious
Posts: 2
Joined: Sat Jul 04, 2015 2:41 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem compiling Dynamic C++ Libray

Post 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
Post Reply