Table of Contents

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.

For full debugging support you need to compile all involved dependencies with debug symbols. Consult the debug notes on the Windows Build page for further information.

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.

  1. Start Qt Creator and go to Tools › Options.
  2. On the Qt4 page add a Qt installation: Add button, then Browse for the appropriate qmake.exe.
  3. 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 is C:\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 version gdb.exe seems to work with Qt Creator 2.5 beta, despire an error message about missing “Qt debugging helpers”.)
  4. 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.
  5. In the left sidebar go to the Projects page and under Edit build configuration switch to the Debug config.
  6. 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.
  7. Setup make for your CPU cores, i.e. in Make arguments enter -j2 for a dual-core CPU, -j4 for a quad-core CPU etc.
  8. 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 bin folders to the PATH variable. 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 LDFLAGS and set it to -LC:/tc/MinGW32/my/lib (forward slashes!)
    • Add CFLAGS and set it to -IC:/tc/MinGW32/my/include (forward slashes!)
    • Add CXXFLAGS and set it to -IC:/tc/MinGW32/my/include (forward slashes!)
    • Add PKG_CONFIG_PATH and set it to C:/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

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.