我正在尝试安装阶段,但我目前被困在这个错误上,出现在[%49]:
[ 49%] Linking CXX shared library libstage.so
/usr/bin/ld: CMakeFiles/stage.dir/blockgroup.o: relocation R_X86_64_PC32 against symbol `_ZTVN3Stg4PoseE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
libstage/CMakeFiles/stage.dir/build.make:981: recipe for target 'libstage/libstage.so.3.2.2' failed
make[2]: *** [libstage/libstage.so.3.2.2] Error 1
CMakeFiles/Makefile2:124: recipe for target 'libstage/CMakeFiles/stage.dir/all' failed
make[1]: *** [libstage/CMakeFiles/stage.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
我尝试查找如何修复它,但我找不到任何对 Linux 新手友好的方法,我该如何修复它?我该如何使用 -fPIC 重新编译?我不知道该怎么做。
任何帮助将不胜感激。
答案1
将 cmake 的设置添加到CMakeLists.txt
:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -no-pie")