简体   繁体   English

pip 安装编译失败并出现错误要求我“使用 -fPIC 重新编译”

[英]pip install compilation fails with error ask me to "recompile with -fPIC"

I tried to build pycolmap with the source code, but I got the error below.我尝试使用源代码构建 pycolmap,但出现以下错误。 According to the googling result, I add these CXX_FLAGS in the CMAKELISTS.txt but it still doesn't work.根据谷歌搜索结果,我在 CMAKELISTS.txt 中添加了这些 CXX_FLAGS,但它仍然不起作用。

 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-pie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie")
/usr/bin/ld: /tmp/ccoE4GQR.ltrans0.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans1.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans2.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans3.ltrans.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans4.ltrans.o: relocation R_X86_64_32 against undefined symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans5.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZZN8pybind1112cpp_function10initializeIZNS_6class_IN6colmap19SiftMatchingOptionsEJEE13def_readwriteIS4_bJA72_cEEERS5_PKcMT_T0_DpRKT1_EUlRKS4_E_RKbJSJ_EJNS_9is_methodEEEEvOSB_PFSC_DpSE_EDpRKT2_ENUlRNS_6detail13function_callEE1_4_FUNESY_.lto_priv.3134' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans6.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans7.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap13RANSACOptionsE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans8.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap22SpatialMatchingOptionsE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans9.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap21SiftExtractionOptionsE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans10.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap3mvs19StereoFusionOptionsE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans11.ltrans.o: relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans12.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap23IncrementalTriangulatorE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans13.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap7Point2DE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans14.ltrans.o: relocation R_X86_64_32 against undefined symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans15.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap14ReconstructionE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans16.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN8pybind116detail14iterator_stateINS0_19iterator_key_accessINSt8__detail14_Node_iteratorISt4pairIKjN6colmap6CameraEELb0ELb0EEES6_EELNS_19return_value_policyE6ESA_SA_RS6_JEEE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans17.ltrans.o: relocation R_X86_64_32S against hidden symbol `_ZTIN6colmap6CameraE' can not be used when making a shared object
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans18.ltrans.o: relocation R_X86_64_32 against undefined symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans19.ltrans.o: relocation R_X86_64_32 against undefined symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans20.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans21.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans22.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans23.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans24.ltrans.o: relocation R_X86_64_32 against undefined symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans25.ltrans.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans26.ltrans.o: relocation R_X86_64_32S against symbol `_ZTVNSt13__future_base13_State_baseV2E' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans27.ltrans.o: relocation R_X86_64_32S against symbol `_ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE@@GLIBCXX_3.4.21' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans28.ltrans.o: relocation R_X86_64_32 against `.LC0' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans29.ltrans.o: relocation R_X86_64_32S against symbol `_ZTINSt8__detail12_CharMatcherINSt7__cxx1112regex_traitsIcEELb1ELb1EEE' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /tmp/ccoE4GQR.ltrans30.ltrans.o: relocation R_X86_64_32S against undefined symbol `_Py_NoneStruct' can not be used when making a shared object; recompile with -fPIC

Anyone knows what's wrong?任何人都知道怎么了? I think maybe I should clean some previous build files, but I don't know how to do this when running我想也许我应该清理一些以前的构建文件,但我不知道在运行时该怎么做

pip install .

I tried set(CMAKE_POSITION_INDEPENDENT_CODE ON) and set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") both according to got-recompile-with-fpic-error .我根据got-recompile-with-fpic-error尝试了set(CMAKE_POSITION_INDEPENDENT_CODE ON)set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

here mentioned that maybe I should try set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-pie")这里提到也许我应该尝试set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-pie")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Lapack链接错误,使用-fPIC重新编译 - Lapack linking error, recompile with -fPIC 构建Boost 1.61 iostream时出错-使用-fPIC重新编译 - Error when building boost 1.61 iostreams - recompile with -fPIC 用-fPIC标志重新编译 - recompile with -fPIC flag 如何使用 -fPIC 重新编译 - How to recompile with -fPIC 创建共享对象时无法使用“获取错误”; 使用-fPIC重新编译-fPIC” - Getting error “can not be used when making a shared object; recompile with -fPIC” although fpic is used “使用-fPIC重新编译”-但是使用-fPIC重新编译无法解决 - “Recompile with -fPIC” - But recompiling with -fPIC doesn't fix log4cxx 使用 -fPIC 重新编译 - log4cxx recompile with -fPIC Linker 错误:“针对符号‘xmlFree’重新定位 R_X86_64_PC32 ... 使用 -fPIC 重新编译”但有问题的库已经使用 -fPIC 编译 - Linker error: “relocation R_X86_64_PC32 against symbol `xmlFree' … recompile with -fPIC” but offending library was already compiled with -fPIC 制作共享库时,不能使用生成错误cmake; 用-fPIC重新编译 - Building error, cmake, can not be used when making a shared object; recompile with -fPIC g++ 编译错误:创建共享对象时不能使用`.rodata'; 用 -fPIC 重新编译 - g++ compile error: `.rodata' can not be used when making a shared object; recompile with -fPIC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM