PDA

View Full Version : How to debug in QtCreator on Ubuntu Linux



Weichao
25th June 2017, 22:02
On Windows debugging in QtCreator is quite simple. But I've not managed to do the same on Ubuntu Linux. I got the message that no debug version is built. What should I do in order to be able to debug?
(The same question is in the forum general discussion as a reply to my own question how to install gdb on Ubuntu, since this seems to be more suitable there. Now I think the debug question is a topic for this forum. Excuse me for double posting.)

Weichao
26th June 2017, 06:12
Now I've written the following program on Linux for debugging:
#include <QtCore/QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
double a, b, c;
a = 1.3f;
b = 2.6f;
c = a / b;
cout << "a / b = " << c << endl;
return app.exec();
}
I've set a breakpoint at the line "a = 1.3f;". But if I started debugging, the program seems to execute over it and I got the result window showing "a / b = 0.5". The editor window is now separated into several little windows which show the debug state. But I can not really debug. What's the correct step to debug on Linux? On Windows this should work well.

Dax
26th June 2017, 10:17
You can try or check the following points:
(I assume that you are using qmake.)

1. In the project settings under 'Build Settings' you can select 'Debug' as build configuration.
2. Add the following line in the qmake .pro file: QMAKE_CXXFLAGS += -O0 -ggdb -fno-omit-frame-pointer -fno-limit-debug-info
This might not be the right qmake variable because this one is independent from the Build Settings.
Not sure the two -f... flags are needed.