Qt Creator IDE
Debugging with Qt Creator
This is a very short tutorial on how to setup Qt Creator on Windows as your debugging environment for Photivo. It is based on Qt Creator 2.3 and assumes you are familiar with compiling Photivo on Windows and have setup your toolchain as explained there.
You actually can run the debugger with some non-debug dependencies and most likely that will work fine as long as you only use those parts of Photivo that don’t rely on those dependencies. In my experience a segfault happens when Photivo with the debugger attached tries to access a non-debug dependency. Example: Debugging with a non-debug lensfun DLL will work as long as you do not actually use the lensfun tools. Effectively this means you must compile a debug version of at least Qt. Debug versions of the other libs might or might not be necessary.
- Start Qt Creator and go to Tools › Options.
- On the Qt4 page add a Qt installation: Add button, then Browse for the appropriate
qmake.exe. - On the Tool Chains page Add a MinGW toolchain and set the Compiler path to the appropriate
g++.exe. Qt Creator will try to automatically set Debugger and ABI accordingly. Make sure the debugger isC:\tc\MinGW32\bin\gdb-python27.exe. (This Python enabled debugger crashes for me with the TDM 4.6.1 toolchain and Qt Creator 2.4.1. The non-python versiongdb.exeseems to work with Qt Creator 2.5 beta, despire an error message about missing “Qt debugging helpers”.) - Open
photivoProject.pro. When the Project Setup dialog appears make sure Use Shadow Building is checked and you have an entry for release and debug version. Photivo’s Mercurial repository is configured to ignore paths starting with “build”, so it’s a good idea to choose names accordingly. - In the left sidebar go to the Projects page and under Edit build configuration switch to the Debug config.
- Under Build Steps open the details for Make. If necessary change the make program to Msys’s make (i.e.
C:\tc\MinGW32\msys\bin\make.exe) is known to work. I had problems with the one from MinGW (that Qt selects by default) and multicore compiling. - Setup
makefor your CPU cores, i.e. in Make arguments enter-j2for a dual-core CPU,-j4for a quad-core CPU etc. - Open the Build Environment details. You need to add a couple of paths here. Adding all of this to your system environment should work as well, but I never tested it that way.
- Add all needed
binfolders to thePATHvariable. Those are:
C:\tc\MinGW32\bin
C:\tc\MinGW32\qt\bin
C:\tc\MinGW32\qt\lib
C:\tc\MinGW32\msys\bin
C:\tc\MinGW32\my\bin
Some may already have been added automatically by Qt Creator. Make sure to use the backslash \ as the path delimiter. - Add
LDFLAGSand set it to-LC:/tc/MinGW32/my/lib(forward slashes!) - Add
CFLAGSand set it to-IC:/tc/MinGW32/my/include(forward slashes!) - Add
CXXFLAGSand set it to-IC:/tc/MinGW32/my/include(forward slashes!) - Add
PKG_CONFIG_PATHand set it toC:/tc/MinGW32/my/lib/pkgconfig(forward slashes!)
Assuming your MinGW toolchain is correct and you successfully built all dependencies debugging should work now.
Additional information for gcc 4.7 toolchain
- Problem: QtCreator doesn't recognize the Qt installation (in my case Qt 4.8.2).
Solution: Copylibwinpthread-1.dllinto qt\bin folder.
Multithreaded make in Creator
When compiling via pure MinGW without Msys – as is the case in Qt Creator – make does not recognise the -j switch properly, i.e. compiling is single-threaded and slow. You can solve this in Creator’s Build Environment settings (see above). Define
MAKE_COMMAND=mingw32-make -j4
and you’re good. Instead of 4 use your number of processor cores.
