简体   繁体   English

为什么我的断点不能在Qt Creator中运行

[英]Why won't my breakpoints work in Qt Creator

Qt creator can build and run my projects perfectly, but it will skip straight over any breakpoints I set. Qt创建者可以完美地构建和运行我的项目,但它会直接跳过我设置的任何断点。 I can't find any options to fix this, and I'd appreciate some help. 我找不到任何方法来解决这个问题,我会感激一些帮助。

EDIT: The SDK is built in debug mode, and the project build configuration is set to debug. 编辑:SDK以调试模式构建,项目构建配置设置为调试。

If this is a cmake build, you need to set the build type before setting the project, so eg in your top CMakeList.txt: 如果这是一个cmake构建,你需要设置项目之前设置构建类型,例如在你的顶级CMakeList.txt中:

SET(CMAKE_BUILD_TYPE Debug)
project(mybuildtype)

Officially, you can pass this also to cmake in Projects section when running cmake: http://qt-project.org/forums/viewthread/12694 , so with -DCMAKE_BUILD_TYPE=Debug flag, but this does not longer seem to work... If you want a flag working, you need to test on it before setting the project, see http://www.cmake.org/pipermail/cmake/2008-September/023808.html 正式地,您可以在运行cmake时将其传递给项目部分中的cmake: http//qt-project.org/forums/viewthread/12694 ,所以使用-DCMAKE_BUILD_TYPE = Debug标志,但这似乎不再起作用..如果你想要一个标志工作,你需要在设置项目之前对其进行测试,参见http://www.cmake.org/pipermail/cmake/2008-September/023808.html

Qt Creator has two modes of running your app: "run" and "debug". Qt Creator有两种运行应用程序的模式:“运行”和“调试”。 I think you may be confused as to what they mean: 我想你可能会对它们的意思感到困惑:

  • Run: launch the program, exactly the same as double-clicking on the executable. 运行:启动程序,与双击可执行文件完全相同。
  • Debug: launch the debugger, attach it to the executable, and run the executable through the debugger. 调试:启动调试器,将其附加到可执行文件,然后通过调试器运行可执行文件。 This records all steps (function calls etc.) your program has, including breakpoints. 这记录了程序的所有步骤(函数调用等),包括断点。

In short: when you need to figure out an internal value during program execution and/or have set breakpoints, use Debug. 简而言之:当您需要在程序执行期间找出内部值和/或设置断点时,请使用Debug。 For anything else, just run it, which is a lot faster. 对于其他任何事情,只需运行它,这要快得多。

You need to add in .pro file next line: 你需要在下一行添加.pro文件:

CONFIG     += debug

And may be you need to delete this: 也许你需要删除这个:

CONFIG     += release

I hope this will help someone who has the same problem. 我希望这能帮助那些遇到同样问题的人。 Even I set it debug mode, but the output files was put on release folder, when I looked at my .pro file, I found this line 即使我设置它的调试模式,但输出文件放在release文件夹上,当我查看我的.pro文件时,我发现这行

CONFIG += qt warn_on release rtti exceptions

Then I remove "release", then it worked. 然后我删除“释放”,然后它工作。 Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM