weird linking breaks debugging?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

weird linking breaks debugging?

Victor Mataré
Hi all,

On Linux, if I'm creating a lib and an executable:

add_library(something SHARED ${LIB_SRC})
add_executable(some-exec ${EXEC_SRC})
target_link_libraries(some-exec something)

Then the linker always links against instead of -lsomething.
For some reason this causes the shared object to be compiled into the the binary:

$ ldd some-exec (0x00007ffd1292b000) (0x00007fd9b346e000)

It's nice I can run the binary without setting LD_LIBRARY_PATH, but the debugger doesn't like it. When debugging some-exec, I can't autocomplete any symbols from the lib, and I can't set breakpoints there. If gdb somehow stops within a frame in libsomething, the symbols become available and I can debug normally.

In qt-creator it's even worse, there my breakpoints end up in all the wrong places and I can't get the program to stop inside the libsomething in a controlled manner.

So how do I tell cmake not to produce one huge mess of a binary? I've tried setting NO_SONAME to 1, but that doesn't change anything. Also, why doesn't cmake just use DT_RUNPATH=$ORIGIN?

Thanks, Victor


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: