I use Qt Creator for C++ projects (non-Qt actually). This might be a dumb question, but how do you manage to use the debugger in Qt Creator? I have been using CDB along with VisualStudio or gdb along with IDEs like Code::Blocks and they are all intuitive to use. When it comes to Qt Creator though, I'm hopeless!
For instance, I've tried putting breakpoints, but when I run the code, it just skips the breakpoints without doing anything! What am I doing wrong?
You should make "Debug" target, not "Release" one (located projects tab -> build settings -> build configuration)
You should use Debug menu items "Start debugging", "Step over", "Continue" etc, not just "Run"
hope it helps.
Related
I am using Qt creator and cdb debugger for my c++ project. I need to set some breakpoints in code and see what happens during runtime. Unfortunately because of some third party library I absolutely can not use Debug mode so I have to stick to the release mode.
In visual studio I always do such thing and use breakpoints in the release mode easily but how could I do that in Qt creator?
(Versions: Qt 5.12 / Qt creator 4.8)
Try using a "Profile" build in Qt Creator. That will include separate debugging line information in a "Release" (optimized) build. You can then launch it using the Debug button in Qt Creator and set breakpoints as you need.
Caveats:
You may not be able to get the exact line you want because of optimizations by the compiler.
You most variables will be optimized into registers, so you can't view them. If you need to view registers, try the good, old fashion method of printing their values out with a qDebug() statement. (When in doubt, print it out.)
I have recently installed Qt Creator 4.8.0 based on Qt 5.12.0 and I have it configured like in the image below. However, I haven't managed to start the debugger. As it can be seen, the debugger is correctly set for this kit, the one I'm using right now.
Any solution?
Thanks!
Wow! I found it!!! Here in the tab "projects", there are several build and run configurations. Despite you select a default kit, the final one being executed is the one in black under this tab.
Finally I disabled all of them except the one that was properly configured in the Kits window and it worked. I hope this information is helpful for someone. I don't think that part of the configuration is clear.
I got the same error, but in my case I was using the MSVC compiler and the kit didn't manage to find the CDB debugger. I was able to fix it by going to "Add or remove programs" -> "Windows Software Development Kit" -> Modify -> Change -> Debugging Tools for Windows.
In my case it was needed to select "Enable C++" under Debugger settings
screenshot
The same dumm error QT creator shows when you simply don't have gdb installed.
Worked in my case ;)
I had the same error in MacOS, debugger suddenly stopped working (LLDB debugger worked in XCode but not Qt Creator).
In this case, I reinstalled Qt Creator and reinitialized the config by removing the .config/QtProject directory located in homedir. This solved the problem.
I had the same issue when Qt Creator didn't recognized the path to the Debugger. Due to some reason it showed multiple Auto-detected Debuggers at the same location. And on the top one of the list with the red error indicator.
see
Projects->Manage Kits...->Debuggers
I removed the erroneous Debugger and restart the Qt Creator.
As a sub-question to this, I want to know, since Qt5 is distributed with full source code, is it possible to set up debugger break-points inside Qt itself?
Is there a symbol file shipped with Qt5 for the binary build? Do I have to build my own Qt to do this?
What is the fastest way to have breakpoints inside Qt5 working with QtCreator on Ubuntu?
You need to configure and build qt yourself with debug symbols. (-debug)
Then in QtCreator you can go to Options > Debugger > General and "Add the Qt-Sources".
I am aware about how to add compiler in Qt Creator. However my Qt always chooses MSVC compiler. How to set MinGW (built-in or external) instead of MSVC?
Couldn't find any post which can help a newbie to know how to change the compiler of desired preference. My current system is Windows, however information on Linux (g++ <--> clang++) is also welcome.
Following is the way with Qt 5.9:
While configuring a new project, select only those compilers/kits which are required;
For 64-bit system, get the latest MinGW and install in a suitable path; While installing MinGW64, you may select "posix threads", and not "win32 threads" to allow threading related libraries
Go to Tools > Options > Build & Run > Compilers and add a manual C++ compiler. Choose the path of where you installed C:/MinGW64/bin/g++.exe (name it something like "MinGW64"); Similarly you may add C compiler as well with C:/MinGW64/bin/gcc.exe; Click 'Apply'
In the same dialog box, select the Debuggers tab and similarly add C:/MinGW64/bin/gdb.exe (name it like "MinGW64 Debugger); Click 'Apply'
In the same dialog box, select the Qt Versions and add a new Kit with MinGW64 like name; However I couldn't find an appropriate qmake.exe for it; Hence, I decided to use the same qmake.exe, which came with built-in 32 bit MinGW within Qt package (not sure about this as of now)
In the same dialog box, now select the Kits tab and add a new Manual kit; You may also follow the way the default MinGW32 bit compiler is configured; Configure Compiler, Debugger and Qt Version for this newly named kit; Click 'Ok'
On the left pan of Qt creator, click on "Projects" tab, and go to "Build & Run" option there; To avoid confusion, you may disable all the kits which are not required; Just keep the relevant kit and click "Build" with either "Debug" or "Release" setting
How do I step through the program one line at time.
Also, how do I view the console input?
I recently installed Eclipse IDE here:
http://www.eclipse.org/downloads/
Eclipse IDE for C/C++ Developers (includes Incubating components)
Go to Run, Debug Configurations and click the Debugger tab.
Make sure that there is a gdb debugger selected. If not click Browse find the gdb.exe. It will probably be in your installation directory (of eclipse I mean under the /bin subdir).
Hope it helped. :D