1

I'm trying to compile a shared library (windows equivalent of a .dll) and it gives me the following error:

usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginT.o: error adding symbols: Bad value

I've never seen this error before. Ever. I'm using codeblocks and g++ 4.8.1. What causes this error?

I'm compiling my own code using:

g++ -shared  obj/Debug/src/Bitmap.o obj/Debug/src/Exports.o obj/Debug/src/Hooks.o obj/Debug/src/main.o obj/Debug/src/Platform.o obj/Debug/src/SharedMemory.o obj/Debug/src/SmartJNI.o  -o bin/Debug/libGLXColour.so -libGL.so -pthread  
/usr/bin/ld: obj/Debug/src/Bitmap.o
Brandon
  • 22,723
  • 11
  • 93
  • 186
  • Did you follow the instruction given in the linker error? Did you Google it? – Lightness Races in Orbit Jan 25 '14 at 15:53
  • I googled the error. I only see DETOUR_END error. Seems similar to mine. I'm not actually sure how to recompile it with -fPIC. – Brandon Jan 25 '14 at 15:55
  • 3
    @CantChooseUsernames you may want to take look at: ["Apply either --enable-shared or -fPIC on in Code::Blocks"](http://stackoverflow.com/q/11380445/2419207) – iljau Jan 25 '14 at 16:00
  • Ah thank you! Wasn't sure why that error was happening in the first place. That worked. – Brandon Jan 25 '14 at 16:05
  • 2
    And also: ["What does -fPIC mean when building a shared library?"](http://stackoverflow.com/q/966960/2419207) – iljau Jan 25 '14 at 16:05

0 Answers0