Apply either --enable-shared or -fPIC on in Code::Blocks

♀尐吖头ヾ 提交于 2020-01-14 04:40:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!