0

当我使用 cmake 构建项目时,出现以下错误。尽管我尝试在 CMakeLists.txt 中添加编译标志-fPICadd_definition()但此错误仍然存​​在。任何人都可以帮忙吗?我是的新手。任何建议将不胜感激。

/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
4

1 回答 1

1

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

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

至于错误本身,请参阅this answer

于 2014-09-18T06:44:07.523 回答