< ^ >

Some debugging notes

So let’s say you have a nice c++ project which has a few dependencies. You might want to add those to you cmake file using something like

find_package(LIBRARY)
target_link_libraries(project PRIVATE ${LIBRARY})

but then what to do if the linking fails? Usually you get an undefined symbol error, with the symbol given in some mangled string. You can unmangle the string, and check out what symbol you are missing, by using

c++filt mangledstring

There are two types of linking, static and dynamic. In the static case you link against .a files, and the contents of that file are included at link time. In the case of dynamic linking a pointer to an .so file being linked.

To check out the list of linked files use

ldd filename

or

readelf --dynamic filename

To have a look at the symbols defined in a file use

nm -gDC filename

The c++ ABI has changed with time, which might cause some problems…