0
我試圖編譯this git-repository遇到錯誤「與-fPIC編譯」:與而選項被傳遞給鏈接
option(BUILD_PYTHON_BINDINGS "Whether or not a binary python module should be built" ON)
This is the output of the compilation(分支功能pybind),但最有趣的部分是:
[100%] Linking CXX shared module pyVFRendering.cpython-34m.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/pyVFRendering.dir/link.txt --verbose=1
/usr/bin/clang++ -fPIC -shared -o pyVFRendering.cpython-34m.so CMakeFiles/pyVFRendering.dir/python/vfrendering_bindings.cpp.o -flto libVFRendering.a qhull-prefix/src/qhull-build/libqhullcpp.a qhull-prefix/src/qhull-build/libqhullstatic_r.a
/usr/bin/ld: libVFRendering.a(ArrowRenderer.cxx.o): relocation R_X86_64_32S against `glad_glGenVertexArrays' can not be used when making a shared object; recompile with -fPIC
libVFRendering.a: error adding symbols: Bad value
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/pyVFRendering.dir/build.make:97: recipe for target 'pyVFRendering.cpython-34m.so' failed
make[2]: *** [pyVFRendering.cpython-34m.so] Error 1
make[2]: Leaving directory '/home/matthias/VFRendering/build'
CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/pyVFRendering.dir/all' failed
make[1]: *** [CMakeFiles/pyVFRendering.dir/all] Error 2
make[1]: Leaving directory '/home/matthias/VFRendering/build'
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
CC=clang: Kommando nicht gefunden
很明顯,我通過-fPIC標誌來叮噹聲。我不太瞭解錯誤信息。 ld抱怨什麼?我怎樣才能解決這個問題?
由於某些原因,即使我使用set(CMAKE_POSITION_INDEPENDENT_CODE ON),此標誌也不會用於編譯ArrowRenderer.cxx.o,您是對的。我如何正確強制CMake使用這個標誌? – Stein
'set(CMAKE_CXX_FLAGS「-fPIC」)'可能是一種方法。否則,請查看源代碼並查看它的設置。共享庫通常在CMake中默認使用fPIC,所以項目中可能會出現某些問題。 –
事實證明,我不得不將它傳遞給子項目QHULL。然後它工作。正確的標誌是CMAKE_POSITION_INDEPENDENT_CODE ON – Stein