我正在尝试使用
编译this git-repository(branch:feature-pybind)option(BUILD_PYTHON_BINDINGS "Whether or not a binary python module should be built" ON)
This is the output of the compilation,但有趣的部分是:
[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标志传递给clang。我真的不明白错误信息。什么是抱怨?我该如何解决这个问题?
答案 0 :(得分:1)
链接时传递-fPIC
但编译时可能不传递。编译时也应该传递它。
我认为这里真正的问题是你似乎试图用几个静态库创建一个共享库。那是不对的:你应该从目标文件创建它(当然用-fPIC编译)。