TheBlueMan
TheBlueMan

Reputation: 427

Cmake - not creating the dynamic links

The project that I am compiling is not linking my shared object file to the main program. This can be confirmed by doing the ldd command on my executable and seeing it say libba.so => not found.

Inside my CMakeLists.txt file I have:

add_library(ba SHARED "/usr/local/include/libba.cpp" "/usr/local/include/libba.h")
target_link_libraries(ba (list of other libraries that link to ba))
set_target_properties(ba PROPERTIES LINK_INTERFACE_LIBRARIES "" LINK_FLAGS "${NO_UNDEFINED}")
add_executable(run "/usr/local/main/run.cpp")
target_link_libraries(run ba)

Upvotes: 0

Views: 30

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 81052

ldd reports what the run-time linker can find.

If you see libba.so in the output it means the binary is linked to the library.

The "not found" means the run-time linker can't find that library (i.e. you don't have it installed in a normal system location).

So you can either install your library to a system location, configure your run-time linker to know about your custom location, link your application statically, or use an rpath in your binary to have it give the run-time linker additional places to look for just itself.

Upvotes: 1

Related Questions