我有一个要构建的项目(不是我的)。它具有必须绑定(bind)的 c++ 和 Python 模块。当我启动 cmake 时,出现此错误:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libantlr.a(BitSet.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libantlr.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [python/CModule.so] Error 1
make[1]: *** [pyBinding/CMakeFiles/CMODULE.dir/all] Error 2
make: *** [all] Error 2
我用 apt-get 安装了 antlr 库,据我所知,我应该重新编译这个库,但我不知道我应该在 antlr 库的源代码的哪一部分放 -fPIC,或者有其他方法吗?
最佳答案
在 Ubuntu 14.10 中,我有包 libantlr-dev
,其中包含 libantlr.a
以及 libantlr-pic.a
。我相信你必须使用后一个,它是用 PIC 编译的
关于c++ - 使用 -fPIcflags重新编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29200461/