简体   繁体   中英

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-项目源代码树

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

主要切入点

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

拆卸

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

调试设置-源路径

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.

As a compliment to the accepted answer, it's worth noting that if the user's configuration uses Shadow Building , we can rephrase the configuration as:

unix:CONFIG(release): LIBS += -L$$PWD/../../path/to/release/folder/ -lLibrary
unix:CONFIG(debug):   LIBS += -L$$PWD/../../path/to/debug/folder/   -lLibrary

Where /path/to/release|debug/folder 's location is at the same level as the source|project file directory, and -lLibrary is the binary library to be linked which resides within the specified -L... path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM