June 20, 2011

mkae mkae
Lab Rat
40 posts

How to successfully create a debuggable Qt application on Mac OS X?


I’m trying already quite a while to build a KDE application which can be debugged using gdb or Xcode on Mac OSX.

Although the release version of the app runs fine – at least up to the point which I actually want to debug – the debug version(s) crash right at the start!!!

The code can be found in folder AboutBoxCrash in this zip [bitbucket.org]

I read the articles http://developer.qt.nokia.com/doc/qt-4.7/debug.html and http://developer.qt.nokia.com/wiki/Mac_OS_X_Troubleshooting, followed their advice, but nothing seems to work out.

No, I didn’t try the dsymutil-trick of this one here: http://stackoverflow.com/questions/1136734/installing-debug-version-of-qt-on-mac-osx yet…


But I can imagine that I am not the only Lab Rat who would love to be able to get a QT Qt app into a debugger on Mac OSX


Yes, this is related to the thread Crash when trying to start KMyMoney with QT Qt 4.7.3 debug version [developer.qt.nokia.com] and I hope that the new title attracts someone who can help. :-)

1 reply

July 22, 2011

mkae mkae
Lab Rat
40 posts

OK, I am back again.

In the meantime I understood – thanks to an advice from Ian Wadham – that the configure option

  1. -no-separate-debug-info

could be used when building QT4.

In the configure options setup I also found that

  1. -debug-and-release

was actually set which always produced both lib versions being very likely the reason for unintended linking between release and debug library version, eventually being responsible for the crashing debug version of the application under test…

So, I changed the configure options now to

  1. configure.args-append -debug -no-separate-debug-info

I can verify that now only debug versions of the respective QT libs are installed:

  1. ...
  2. /opt/macports-test.new/lib/libQtCore_debug.4.7.3.dylib
  3. /opt/macports-test.new/lib/libQtCore_debug.4.7.dylib
  4. /opt/macports-test.new/lib/libQtCore_debug.4.dylib
  5. /opt/macports-test.new/lib/libQtCore_debug.dylib
  6. /opt/macports-test.new/lib/libQtCore_debug.la
  7. /opt/macports-test.new/lib/libQtCore_debug.prl
  8. ...

But above you can see that all debug libraries have the extension “_debug”.

When I try to build other applications using QT4 (here kdelibs4) I therefore run into other trouble:

  1. ...
  2. :info:build cd /opt/macports-test/var/macports/build/_Users_marko_WC_MacPorts_ports_kde_kdelibs4/work/build/kdecore && /opt/macports-test/bin/automoc4 /opt/macports-test/var/macports/build/_Users_marko_WC_MacPorts_ports_kde_kdelibs4/work/build/kdecore/kauth_backend_plugin_automoc.cpp /opt/macports-test/var/macports/build/_Users_marko_WC_MacPorts_ports_kde
  3. _kdelibs4/work/kdelibs-4.6.5/kdecore /opt/macports-test/var/macports/build/_Users_marko_WC_MacPorts_ports_kde_kdelibs4/
  4. work/build/kdecore /opt/macports-test/bin/moc /opt/macports-test/bin/cmake:info:build dyld: Library not loaded: /opt/macports-test/lib/libQtCore.4.dylib
  5. :info:build   Referenced from: /opt/macports-test/bin/automoc4
  6. :info:build   Reason: image not found
  7. :info:build /bin/sh: line 1: 82423 Trace/BPT trap          /opt/macports-test/bin/automoc4 /opt/macports-test/var/macpo
  8. rts/build/_Users_marko_WC_MacPorts_ports_kde_kdelibs4/work/build/kdecore/kauth-policy-gen_automoc.cpp /opt/macports-tes
  9. t/var/macports/build/_Users_marko_WC_MacPorts_ports_kde_kdelibs4/work/kdelibs-4.6.5/kdecore /opt/macports-test/var/macp
  10. orts/build/_Users_marko_WC_MacPorts_ports_kde_kdelibs4/work/build/kdecore /opt/macports-test/bin/moc /opt/macports-test
  11. /bin/cmake
  12. ...

Above you can see that the build process of kdelibs4 expects to find libQtCore.4.dylib which, of course, cannot be found in my current setup.

I am wondering what can be done to make cmake build QT4 a debug version without appending the “_debug” prefix to the library names.

  ‹‹ [Solved] Passing QByteArray to 3rd party function      Regarding Layout Management ››

You must log in to post a reply. Not a member yet? Register here!