![](/img/trans.png)
[英]Getting error “can not be used when making a shared object; recompile with -fPIC” although fpic is used
[英]Building error, cmake, can not be used when making a shared object; recompile with -fPIC
当我使用cmake构建项目时,出现以下错误。 尽管我尝试通过CMakeLists.txt中的add_definition()
添加编译标志-fPIC
,但该错误仍然存在。 有人可以帮忙吗? 我是新来的家伙的cmake 。 任何建议将不胜感激。
/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
add_definitions用于添加预处理器定义,而不是标志
对于使用GCC构建的共享库,默认情况下-fPIC
存在于链接器标志中,请参见Modules / Compiler / GNU.cmake 。 您可以通过运行make VERBOSE=1
查看所有标志。
至于错误本身,请参阅此答案 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.