0

I am trying to compile this git-repository (branch: feature-pybind) with

option(BUILD_PYTHON_BINDINGS "Whether or not a binary python module should be built" ON) 

This is the output of the compilation, but the interesting part is:

[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 

Clearly I am passing the -fPIC flag to clang. I don't really understand the error message. What is ld complaining about? How can I fix this?

1 Answer 1

1

You are passing -fPIC when linking but probably not when compiling. You should pass it when compiling as well.

I think the real issue here is that you seem to be trying to create a shared library out of several static libraries. That's not right: you should be creating it from object files (compiled with -fPIC of course).

Sign up to request clarification or add additional context in comments.

3 Comments

You're right for some reason this flag isn't used for compiling ArrowRenderer.cxx.o even if I use set(CMAKE_POSITION_INDEPENDENT_CODE ON). How do I properly force CMake to use this flag?
set(CMAKE_CXX_FLAGS "-fPIC") might be one way. Otherwise, look into the source code and see how it's set up. Shared libraries usually use fPIC by default in CMake, so something might be broken in the project.
It turned out that I had to pass it to the subproject QHull aswell. Then it worked. The correct Flag is CMAKE_POSITION_INDEPENDENT_CODE ON

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.