Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stepping into Qt sources in Qt Creator (in Ubuntu Linux)

Tags:

I'm using Qt Creator in Ubuntu. It's installed from the repositories but as it is now, there is no way to step into the Qt sources when debugging.

How can I enable that?

like image 915
sashoalm Avatar asked Feb 19 '11 07:02

sashoalm


People also ask

Where are Qt libraries Ubuntu?

The library files are usually in /usr/include/qt4 .

What is QT Creator in Linux?

Qt Creator is a cross-platform integrated development environment (IDE) built for the maximum developer experience. Qt Creator runs on Windows, Linux, and macOS desktop operating systems and allows developers to create software across desktop, mobile, and embedded platforms.


1 Answers

Since Qt Creator uses gdb, you need to configure gdb. First thing to do is to install Qt debugging symbols:

apt-get install libqt4-dbg 

Or, for Qt5:

apt-get install qtbase5-dbg # For the qtbase package 

This will install the debugging symbols for Qt libraries. Older releases of Ubuntu had a silly bug that required additional trick to correct those symbol files, but in the current release it works fine.

This will make gdb step inside Qt methods, but it's no fun without sources. So we need sources which can be installed like this, assuming that the source repository is enabled in the APT:

apt-get source qt4-x11 ln -s qt4-x11-4.7.0 qt # a convenience symlink 

Or, for Qt5:

apt-get source qtbase-opensource-src # Make a link as above, if you wish 

This will download the sources, unpack them into the current directory and patch them accordingly, no root privileges needed unless the current dir isn't writeable by the current user.

And the last thing is to inform gdb of the sources location, which is done by putting this in the ~/.gdbinit file:

dir ~/vita/qt/src/corelib dir ~/vita/qt/src/gui dir ~/vita/qt/src/network dir ~/vita/qt/src/sql 

Add modules and correct paths as needed. The convenience symlink is very useful here, so we don't have to edit this file each time we upgrade to a new Qt version. We only need to download the new sources, patch them and change the symlink.

Note that even we have installed the debugging symbols, we still use the release build of Qt libraries. This means that the code is highly optimized and will sometimes behave very strange when stepping inside Qt binaries. If it is a problem, then it is necessary to build Qt in debug mode, install it separately (say, in /usr/local/qt4-debug) and tell Qt Creator to use that particular installation.

like image 55
Sergei Tachenov Avatar answered Oct 15 '22 13:10

Sergei Tachenov