I'm learning CMake.
My project consists of an executable and a shared library. The shared library can be used by third party projects. The executable and the shared library will be installed in the system.
I have two modes of development: debug and release. Simply, I define an option and, depending on the value of the option, set a value to the CMAKE_BUILD_TYPE variable.
I link the executable with the shared library as follows:
ADD_EXECUTABLE( my_executable ${MY_EXECUTABLE_SOURCE_FILES} )
TARGET_LINK_LIBRARIES(
my_executable
${MY_EXECUTABLE_DEPENDENCIES_LIBRARIES}
my_shared_library #target generated with ADD_LIBRARY
)
My problem is that when I link in release mode and I run the ldd tool:
~/my-project/build$ sudo make install
~/my-project/build$ ldd -d /usr/local/bin/my_executable
my_shared_library.so.0.1 => /path/my-project/output/lib/my_shared_library.so.0.1 (0x00007f1361adb000)
------------------------
local path
when it should be displayed:
my_shared_library.so.0.1 => /usr/local/lib/my_shared_library.so.0.1 (0x00007f1361adb000)
-----------
install path
How can I solve this problem?
Should I create a static library (a part of the shared library) and link the executable with it?
Cheers
ldd
on the executable in the system path from somewhere else than the build path? – TorbjörnCMAKE_BUILD_TYPE
directly on the first invocation of CMake or during building:cmake --build . --target my_executable --config Debug|Shared
– Torbjörnsudo make install
? Try to create a mcve. – Torbjörn