LinuxConsulting

- Nicu Pavel personal page

PaNiC Random Rant (or how we used to call it: .plan)


Monday, August 3, 2009

QMake with Visual Studio: Generating debug information (pdb) files


Working with multiple libraries on different subdirs in Visual Studio using QMake tools brings a problem when you try to debug code that is contained in those libraries: the debug files (pdb) are generated with same name (vc80.pdb or similar) in libraries dirs which results in visual studio being unable to get the right debug information. To fix this problem pdb files need to be renamed and placed in the location where the executable is run for debugging.
As an example we have a main .pro file which it's a subdirs template to compile code in multiple subdirs:

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += mbl_utils \
mbl_usb \
mbl_encoder \
mbl_renderer \
nanoGUI


For each .pro file in the libraries subdirectory we will have to add on a debug:win32 entry the following code:


debug:win32 {
# Hack to get pdb files generated with proper name
QMAKE_CXXFLAGS += -Fd$${TARGET}.pdb
# Hack to get pdb files copied in Bin folder from where the binary is run
pdbtarget.files = $${TARGET}.pdb
pdbtarget.path = $${BINDIR}
pdbtarget.command = copy /y $${TARGET}.pdb $${BINDIR}
INSTALLS += pdbtarget
}


Where TARGET is defined as the library name and BINDIR is where the executable file is copied after compilation. This should create proper debug information files where the project executable is being run.

Labels: , , ,

posted by panic @ 12:44 PM 0 Comments