Results 1 to 11 of 11

Thread: Not able to debug Qt

  1. #1
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Not able to debug Qt

    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/Buildi...isual_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.

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not able to debug Qt

    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".

  3. The following user says thank you to spud for this useful post:

    S_N (4th April 2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Not able to debug Qt

    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..

    Quote Originally Posted by spud View Post
    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".

  5. #4
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not able to debug Qt

    Quote Originally Posted by S_N View Post
    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?

  6. #5
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: Not able to debug Qt

    I havent installed any patch.
    Do I need to install any patch?? Is that the thing I am missing?

  7. #6
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not able to debug Qt

    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?

  8. #7
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Not able to debug Qt

    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?

  9. #8
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not able to debug Qt

    Quote Originally Posted by S_N View Post
    Do you have any idea?
    Not really
    Check the generated makefiles for the compiler flag -Zi (generate program database).
    My "%QTDIR%\src\corelib\Makefile.Debug" says
    Qt Code:
    1. CXXFLAGS = -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -W3 -w34100 -w34189 -GR -EHsc $(DEFINES)
    To copy to clipboard, switch view to plain text mode 

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

  10. #9
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Not able to debug Qt

    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

  11. #10
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not able to debug Qt

    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.

  12. #11
    Join Date
    Apr 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Not able to debug Qt

    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...
    Anyways thanks for you help!!

Similar Threads

  1. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 17:48
  2. Replies: 2
    Last Post: 8th November 2007, 21:15
  3. What is debug mode for without MSVC?
    By firegun9 in forum Newbie
    Replies: 1
    Last Post: 5th September 2007, 18:21
  4. Qt4 open src mingw from a PC to another
    By nvictor in forum Installation and Deployment
    Replies: 11
    Last Post: 1st May 2007, 18:41
  5. Adding custom defines when on debug build
    By chus in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2007, 12:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.