c++ - 使用 -fPIcflags重新编译

标签 c++ fpic

我有一个要构建的项目(不是我的)。它具有必须绑定(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/

相关文章:

c++ - 构建错误,cmake,制作共享对象时无法使用;使用 -fPIC 重新编译

c++ - 计算和存储非常大数的幂

gcc - `-fpic` 和 `-fPIC` gcc 参数有什么区别?

c - gcc 优化对共享库操作的影响

c++ - gcc 与 clang : inlining a function with -fPIC

makefile - 使用-fPIC选项重新编译,但该选项已在makefile中

c++ - OpenGL 在 3D 空间中渲染 2D

c++ - 为缺少 XML 文档启用 C++ 编译器警告

c++ - 按值传递容器会使迭代器无效吗?

c++使用数据类型声明指定数据长度