PDA

View Full Version : Not able to debug Qt



S_N
4th April 2008, 07:55
Hello experts,

I am new to Qt. I have downloaded its latest version 4.3.4 (windows open source) from Trolltech site and built it for MSVC2005 compiler according to the stpes given on the following link
http://wiki.qgis.org/qgiswiki/Building_QT_4_with_Visual_C++_2005
I build it for debug libraries. It got build properly without any error. Now using these libraries I compiled a simple application to display "Hello World" on a button. The application also got complied successfully. (This application I build with "qmake -project CONFIG+=debug" command in order to make it debuggable) now when I opened this application in MSVC2005 IDE for debug, it’s not allowing me to step inside Qt’s code.
The code of the application is like this:
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QPushButton hello("Hello world!");
hello.resize(100, 30);

hello.show();
return app.exec();
}
Now I want to see the code flow inside function hello.resize() or hello.show(). The application is simply running not allowing me to go inside any function. I would be really grateful if someone can help me doing this.

Thanks.

spud
4th April 2008, 10:04
A couple of questions:

Look in %QTDIR%/bin. Can you find QtCored4.dll, QtGuid4.dll etc?
Look in %QTDIR%/lib. Can you find QtCored4.lib, .pdb, .ilk, .exp?
Check your linker settings. are you linking to QtCored4.lib etc?
While debugging, try setting a breakpoint in a Qt source file. Check if the breakpoint stays active, or read the error message.


There are a lot of guides how to install Qt-win-opensource, because it used to be a bit tricky. Some of them need to be updated, because nowadays all you have to do is unzip and "configure && nmake".

S_N
4th April 2008, 10:45
I have checked %QTDIR%/bin. I have QtCored4.dll, QtGuid4.dll and all other debug dlls there.
I also have QtCored4.lib, .ilk, .exp in %QTDIR%/lib folder. But .pdb is there in the example i am trying to compile as its workspace is there. There is no .pdb in %QTDIR%/lib path.
I tried to place breakpoint in Qt source file but as soon as i start debugging it became inactive. :(
To build Qt I followed all the steps configure -debug then nmake. Build was successful.
I dont know what is the thing I am missing..


A couple of questions:

Look in %QTDIR%/bin. Can you find QtCored4.dll, QtGuid4.dll etc?
Look in %QTDIR%/lib. Can you find QtCored4.lib, .pdb, .ilk, .exp?
Check your linker settings. are you linking to QtCored4.lib etc?
While debugging, try setting a breakpoint in a Qt source file. Check if the breakpoint stays active, or read the error message.


There are a lot of guides how to install Qt-win-opensource, because it used to be a bit tricky. Some of them need to be updated, because nowadays all you have to do is unzip and "configure && nmake".

spud
4th April 2008, 16:04
There is no .pdb in %QTDIR%/lib path.
Well you need them:(

I compiled 4.3.4 with msvc2005 with "configure && nmake" and I have them. I don't now why you shouldn't. Did you install any patch as described in the wiki?

S_N
4th April 2008, 19:22
I havent installed any patch. :(
Do I need to install any patch?? :confused: Is that the thing I am missing?

spud
4th April 2008, 20:05
Nope, you don't need the patch, but the wiki you referred to instructs you to install one.

Say, you didn't run "nmake clean" by any chance?

S_N
4th April 2008, 21:25
I have not installed any patch. And I ran only "nmake" command not "nmake clean" but why there is no .pbd file in my QTDIR\Lib folder?? Do you have any idea?

spud
4th April 2008, 21:37
Do you have any idea?
Not really:confused:
Check the generated makefiles for the compiler flag -Zi (generate program database).
My "%QTDIR%\src\corelib\Makefile.Debug" says
CXXFLAGS = -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -W3 -w34100 -w34189 -GR -EHsc $(DEFINES)

If it's not there you can always add it yourself and rerun nmake.

S_N
7th April 2008, 09:39
I updated CXXFLAGS as mentioned by you in "%QTDIR%\src\corelib\Makefile.Debug" file and then run namke clean and then rebuild it using namke again.
Now there are .pdb files in ""%QTDIR%\lib" folder. I have also checked the linker settings. It is linking to debud libraries only.
But still the problem remains the same.. :(
As soon as I put a break point inside Qt's code and start debugging, it becomes inactive.
Donno why is this happening :(

spud
7th April 2008, 10:43
Did you put the breakpoint in code belonging to the QtCore module? Try setting a breakpoint in, say the constructor of QString. And if it becomes disabled check the error message when you hover the mouse over said breakpoint.

S_N
7th April 2008, 13:17
My problem got resolved!! :)
Actually there was another "QtGuid4.dll" in the example I was compiling. It was linking to this dll. while this was not a debug dll, it was not allowing me to go inside.
I checked this dependency on MS Visual Studio in Debud->Windows->Modules. It shows whether symbols (used while debugging) are loaded or not and the path from where it is taking the .pdb file.
It was my mistake... :o
Anyways thanks for you help!!