Search code examples
c++linuxgdbqt-creatordebug-symbols

Accessing internal project library's debugging symbols in Qt Creator?


I have a project/source tree with sub-directory projects, that look as follows:

Qt Creator - Project Source Tree

The idea is that the exec (testing) project is to make calls from the op (shared-object) library project - both being sub-projects managed by the root project gviewer.

Despite having the gviewer project set as Debug (using GCC x86_64), anytime I try to step into a constructor or class-method/function from the op build, the debugger will just spit out disassembly immediately. I've been having a hard time figuring out whether the issue is the project settings ( -- of which I've looked at and had trouble figuring out which setting could be changed to solve the problem) an issue in the debugger settings (also looked at), or something going on with the project files.

The common.pri file is included by op.pro.

After looking here, and experimenting with various views while trying to load the symbols while debugging, I've come to the conclusion I'm doing something wrong. Whether this is a GDB debug configuration issue, a .pro file issue, or a QtCreator issue is beyond me.

If anyone here has had experience with loading debug symbols using internal project libraries (in this case: shared objects), any insight provided would be appreciated. Thanks.


Project Files:

gviewer.pro

TEMPLATE = subdirs
SUBDIRS  = \
    source/op

CONFIG += ordered
SUBDIRS += source/exec

common.pri

INCLUDEPATH += . ..

TEMPLATE = lib

CONFIG -= qt app_bundle

NO_ERR_FLAGS = -Wno-write-strings -Wno-return-type -Wno-unused-parameter

debug:QMAKE_CXXFLAGS_DEBUG += -Wall -Werror -std=c++11 $$NO_ERR_FLAGS -g

DEFINES += OP_DEBUG OP_PLATFORM_X86

LIBS += -lGL -lGLU -lGLEW -lglfw

op.pro

! include(../common.pri) {
    error( Couldn't find the common.pri file! )
}

HEADERS += \
    debug/glout.hpp \
    math/matrix.hpp \
    math/math.hpp \
    math/glm_incl.hpp \
    io/log.hpp

SOURCES += \
    debug/glout.cpp \
    math/matrix.cpp \
    io/log.cpp

exec.pro

INCLUDEPATH += ../

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle qt

SOURCES += main.cpp

LIBS += -L../op -lop

DESTDIR_TARGET = ../../

Some further images:

exec: entry point - main.cpp

main entry point

op: disassembly - no source loaded after invoking step into
on op::Log::OpenFile(...)

disassembly

debugger source paths - fiddled with the paths here, no such luck; though I'm not sure if I was using this correctly

debug settings - source paths


Solution

  • In your .pro file you have this:

    LIBS += -L../op -lop
    

    If I understood you well, this is where you are linking the library you have problems with. You should, however, link two versions of it, the debug version for the debug build of your project, and the release version for the release version of your project. I don't know what OS are you under, but here's an example for you so you can get the idea:

    unix:CONFIG(release): LIBS += -L$$PWD/../../Filters/release/ -lFilters
    unix:CONFIG(debug): LIBS += -L$$PWD/../../Filters/debug/ -lFilters
    

    Note that the first line links the release library if the current project is being built as release, and the second line is linking the debug library version if the current project is being built as debug.