简体   繁体   English

在 Qt Creator 中运行调试模式

[英]Running debug mode in Qt Creator

I am trying to compile some demo code (specifically, the pcl_visualizer demo that comes with the Point Cloud library).我正在尝试编译一些演示代码(特别是点云库附带的 pcl_visualizer 演示)。 When running debug by clicking the green arrow with the magnifying class, I get the following errors:通过单击带有放大类的绿色​​箭头运行调试时,出现以下错误:

This does not seem to be a "Debug" build.
Setting breakpoints by file name and line number may fail.

Section .debug_info: Not found.
Section .debug_abbrev: Not found.
Section .debug_line: Not found.
Section .debug_str: Not found.
Section .debug_loc: Not found.
Section .debug_range: Not found.
Section .gdb_index: Not found.
Section .note.gnu.build-id: Found.
Section .gnu.hash: Found.
Section .gnu_debuglink: Not found.

Furthermore, none of the breakpoints I have inserted are breaking the program, and they all have little hourglasses hovering over.此外,我插入的所有断点都没有破坏程序,而且它们都有小沙漏悬停在上面。

In Projects , the Debug mode is selected in Build Settings .Projects ,在Build Settings选择Debug模式。

Why does my code not seem to be debugging correctly?为什么我的代码似乎没有正确调试?

Some projects automatically build debug mode and allow to run it individually.一些项目会自动构建调试模式并允许单独运行。 You can then pick it in the bottom left Run selection menu.然后您可以在左下角的Run选择菜单中选择它。

“运行”菜单和“项目”视图的动画

Other projects require you to specifically do a debug build.其他项目需要您专门进行调试构建。

For example: Kdenlive requires you to run CMake again with the following parameter added:例如:Kdenlive 要求您再次运行 CMake,并添加以下参数:

-DCMAKE_BUILD_TYPE=Debug

You can re-run CMake in the Projects view.您可以在“ Projects视图中重新运行 CMake。

For newer versions of QT: Go to "Projects" in the top left of the screen, an icon with a wrench that turns green when you select it.对于较新版本的 QT:转到屏幕左上角的“项目”,一个带有扳手的图标,当您选择它时会变成绿色。

If not already "clicked", click on "Build" under the named Kit (I have "desktop" as my kit).如果尚未“单击”,请单击命名套件下的“构建”(我将“桌面”作为我的套件)。 This should be immediately below "Build & Run" on the left side.这应该在左侧的“Build & Run”下方。

Under Build Settings at the top center, should have "Edit build configuration" with a drop down next to it.在顶部中心的构建设置下,应该有“编辑构建配置”,旁边有一个下拉菜单。 If you can select "Debug" from the drop down then do it, otherwise click "Add" in the drop down next to it and select "Debug".如果您可以从下拉列表中选择“调试”,则执行此操作,否则单击旁边下拉列表中的“添加”并选择“调试”。

Drop down some and see "Key" on the left side of a table of "Key"s with "Value"s, look farther right and see "Advanced" with a square, check the square to get the advanced Key-Value pairs.下拉一些,在带有“值”的“键”表的左侧看到“键”,再向右看,看到带有正方形的“高级”,检查正方形以获取高级键值对。

Look for "CMAKE_BUILD_TYPE" and click "Edit" in the far right, change the drop down for the value matched to the key CMAKE_BUILD_TYPE to "debug".查找“CMAKE_BUILD_TYPE”并单击最右侧的“编辑”,将与键 CMAKE_BUILD_TYPE 匹配的值的下拉列表更改为“调试”。

Now in the bottom left, change the build configuration to "debug" and build... should work!现在在左下角,将构建配置更改为“调试”并构建...应该可以工作!

You may have to Clean the project and possibly clear cmake configuration under the Build tab.您可能需要清理项目并可能清除 Build 选项卡下的 cmake 配置。

Another cause for the "does not appear to be a debug build" message is running gdb using the cdb engine. “似乎不是调试版本”消息的另一个原因是使用 cdb 引擎运行 gdb。 to check go to tools->options->build and run->kits and select the kit you are using.检查转到工具->选项->构建和运行->套件并选择您正在使用的套件。 next go to the debugger line, choose edit, and make sure you have the right engine for your debugger.接下来转到调试器行,选择编辑,并确保您的调试器具有正确的引擎。

在 linux 上使用“Qt 维护工具”安装“Qt 调试信息文件”为我解决了这个问题

I've got the same message because the build type was set to release.我收到了相同的消息,因为构建类型设置为发布。 On Qt Creator 3.3.0 on the bottom left, on top of the play symbol i have a pc icon with the build type.在左下角的 Qt Creator 3.3.0 上,在播放符号的顶部,我有一个带有构建类型的 pc 图标。 click on that icon and select debug.单击该图标并选择调试。 I needed to 'run qmake' too from the menu build.我也需要从菜单构建中“运行 qmake”。

For nasm users with QT5.9.1 and nasm 2.14 the problem will be gone by using: nasm -felf64 -FDwarf -g对于使用 QT5.9.1 和 nasm 2.14 的 nasm 用户,使用以下命令可以解决问题: nasm -felf64 -FDwarf -g

I know it's not c/c++ related but works very well in QT我知道它与 c/c++ 无关,但在 QT 中运行良好

To change the Build Configuration in QT Creator :(at time of writing : 4.13.3)在 QT Creator 中更改构建配置 :(撰写本文时:4.13.3)

Just make sure you have selected this as Debug so that it would then run in debug mode.只需确保您已将其选为 Debug,以便它可以在调试模式下运行。 在此处输入图片说明

我设法通过在调试设置常规选项卡中取消选中“调试发布版本时发出警告”来解决这个问题,如文章中所述: http : //www.kdab.com/qt-on-android-episode-2/

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

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