【问题标题】:Building error, cmake, can not be used when making a shared object; recompile with -fPIC构建错误,cmake,制作共享对象时无法使用;使用 -fPIC 重新编译
【发布时间】:2014-09-18 00:47:45
【问题描述】:

当我使用 cmake 构建项目时,出现以下错误。尽管我尝试在 CMakeLists.txt 中通过add_definition() 添加编译标志-fPIC,但此错误仍然存​​在。任何人都可以帮忙吗?我是 的新人。任何建议都将受到高度赞赏。

/usr/bin/ld: /act/mvapich2-1.9/gcc-4.7.2/lib/libmpich.a(mvapich_malloc.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
/act/mvapich2-1.9/gcc-4.7.2/lib/libmpich.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/libstracker.so] Error 1
make[2]: Leaving directory `/home/xxxx/success/AutomaDeD-master'
make[1]: *** [src/CMakeFiles/stracker.dir/all] Error 2
make[1]: Leaving directory `/home/xxxx/success/AutomaDeD-master'
make: *** [all] Error 2

【问题讨论】:

    标签: cmake c++ build cmake shared fpic


    【解决方案1】:

    add_definitions 旨在添加预处理器定义,而不是标志

    -fPIC 默认存在于使用 GCC 构建的共享库的链接器标志中,请参阅Modules/Compiler/GNU.cmake。您可以通过运行make VERBOSE=1 查看所有标志。

    至于错误本身,见this answer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-22
      • 2018-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      相关资源
      最近更新 更多