问题
As the question states, I need to apply either of those compiler/linker settings. I am using Code::Blocks 10.05. I've looked through all the build settings screens. I cannot find where to apply these settings. I am getting the following on output:
-------------- Build: Release in 39dll-4-Linux ---------------
Linking dynamic library: ./39DLL.so
/usr/bin/ld: obj/Release/buffer.o: relocation R_X86_64_32 against `CBuffer::retval' can not be used when making a shared object; recompile with -fPIC
obj/Release/buffer.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
回答1:
Go to: Project->Build Options->Compiler Settings->Other Options.
On the left you will see a tree with the build targets. It looks like this: ProjectName Debug Release
Click on each node of the tree and for each node enter -fPIC
in the text box, then press OK to save.
That way the flag will be added for all targets.
来源:https://stackoverflow.com/questions/11380445/apply-either-enable-shared-or-fpic-on-in-codeblocks