I'm having a problem with cmake, like One of the libraries which I want to link to my shared library which I'm compiling is boost. So, I tried like:
target_link_libraries(my_project
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_CHRONO_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${Boost_REGEX_LIBRARY}
${Boost_SIGNALS_LIBRARY}
${Boost_THREAD_LIBRARY})
However, when I execute in the terminal to check the linkage
ldd libmy_project.so
libboost_system.so.1.66.0 => not found
libboost_chrono.so.1.66.0 => not found
libboost_date_time.so.1.66.0 => not found
libboost_regex.so.1.66.0 => not found
libboost_signals.so.1.66.0 => not found
libboost_thread.so.1.66.0 => not found
But the boost library was found by the cmake in the CMakeList. Anybody know how to fix this?
Edit:
The problem was to set properly the rpath, I tried to follow the cmake documentation. However, it didn't work for me.
The only thing which worked was adding this line before the target_link_libraries(...)
in CMkaeLists.txt:
set_target_properties(YOUR_PROJECT PROPERTIES LINK_FLAGS "-Wl,-rpath, YOUR_LIB_LOCATION_HERE")