Reputation: 714
I am trying to build an executable that uses several dylibs in the execution path. This works for some, but for one it doesn't and I do not understand why.
otool -L
shows the following:
@rpath/libtuio.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/liburg_library.dylib (compatibility version 0.0.0, current version 0.0.0)
/libIrrlicht.dylib (compatibility version 1.0.0, current version 1.0.0)
The library it does not work for is libIrrlicht
, which, I think, should also have @rpath/
in front of it, but I do not know how to make CMake do that.
Linker command generated by CMake:
/usr/bin/clang++ -g -arch arm64
[...]
-Wl,-rpath,@loader_path/
[...]
bin/libtuio.dylib
bin/liburg_library.dylib
[...]
external/lib_mac_arm/libIrrlicht.dylib
The obvious difference is that libtuio
and liburg_library
are compiled in the process, while libIrrlicht
is precompiled and supplied - but copied to the executable folder post-build.
The relevant section in the CMakeLists.txt is:
target_link_libraries(myBinary [...] ${TUIO_LIB_TARGET} ${URG_LIB_TARGET} ${OSC_LIB_TARGET})
if (MACOSX)
target_link_libraries(myBinary [...] ${IRR_LIB_DIR}/libIrrlicht.dylib opencv_core opencv_video ${OPENSSL_CRYPTO_LIBRARIES} ${SDL2_LIBRARIES})
set_target_properties(myBinary PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
set_property(
TARGET myBinary
PROPERTY INSTALL_RPATH
"@loader_path/"
)
Upvotes: 0
Views: 65