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 libsomething.so instead of -lsomething.
For some reason this causes the shared object to be compiled into the the binary:

$ ldd some-exec
        linux-vdso.so.1 (0x00007ffd1292b000)
        libsomething.so (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 www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake