Skip to content

Building as shared library - Indirect_Predicates questions #3

@starseeker

Description

@starseeker

Starting to work in a fork at building the InteractiveAndRobustMeshBooleans (IRMB) code as a shared library on Linux, I ran into the following: Cinolib is building https://github.com/cinolib-dev-team/Indirect_Predicates as a static library, but that trips up the linking with an eventual linking error:

[81/86] Linking CXX shared library src/libirmb.so
FAILED: src/libirmb.so 
: && /usr/bin/c++ -fPIC -O2 -g -DNDEBUG   -shared -Wl,-soname,libirmb.so -o src/libirmb.so src/CMakeFiles/irmb.dir/booleans.cpp.o src/CMakeFiles/irmb.dir/foctree.cpp.o src/CMakeFiles/irmb.dir/arrangements/io_functions.cpp.o  gnu_11.3_cxx17_64_relwithdebinfo/libtbb.a  /usr/lib/x86_64-linux-gnu/libGL.so  imgui/libimgui.a  imgui/glfw/src/libglfw3.a  /usr/lib/x86_64-linux-gnu/librt.a  -lm  /usr/lib/x86_64-linux-gnu/libX11.so  shewchuk_predicates/libshewchuk_predicates.a  _deps/indirect_predicates-build/libindirectPredicates.a  -ldl && :
/usr/bin/ld: _deps/indirect_predicates-build/libindirectPredicates.a(hand_optimized_predicates.cpp.o): warning: relocation against `_ZN15interval_number4zeroE' in read-only section `.text'
/usr/bin/ld: _deps/indirect_predicates-build/libindirectPredicates.a(implicit_point.cpp.o): relocation R_X86_64_PC32 against symbol `_ZN15interval_number4zeroE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value

This can be fixed by adding set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON) to https://github.com/cinolib-dev-team/Indirect_Predicates/blob/master/CMakeLists.txt but that's presumably not desirable except when trying to make this a shared library. I'm not familiar with the FetchContent_MakeAvailable mechanism being used to pull Indirect_Predicates - is there a way to pass the CMake configure process options from the top-level build?

Also, I notice Indirect_Predicates is using the LGPLv3 license - does Cinolib allow for shared linking with that library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions