在Code :: Blocks中应用--enable-shared或-fPIC

时间:2012-07-08 03:30:38

标签: gcc linker flags fpic

正如问题所述,我需要应用这些编译器/链接器设置中的任何一个。我正在使用Code :: Blocks 10.05。我查看了所有构建设置屏幕。我找不到应用这些设置的位置。我在输出上得到以下信息:

-------------- 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 个答案:

答案 0 :(得分:3)

转到: 项目 - >构建选项 - >编译器设置 - >其他选项。

在左侧,您将看到一个包含构建目标的树。它看起来像这样: 项目名    调试    释放

单击树的每个节点,对于每个节点,在文本框中输入-fPIC,然后按OK保存。 这样就会为所有目标添加标志。