使用 QtCreator 设置 GDB [英] Setup GDB with QtCreator

查看:98
本文介绍了使用 QtCreator 设置 GDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 OpenCV 和 cmake 的简单项目,并且有两个源文件只有 segmentation.h 和 segmentation.cpp.

I have a simple project using OpenCV and cmake, and has two source files only segmentation.h and segmentation.cpp.

这是 cmake 文件:

Here is the cmakefile:

project(Segment)
cmake_minimum_required(VERSION 2.8)

SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_VERBOSE_MAKEFILE true)

if(CMAKE_COMPILER_IS_GNUCXX)
    message(STATUS "GCC detected, adding compile flags")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -std=c++98 -Wall")
endif(CMAKE_COMPILER_IS_GNUCXX)

find_package(OpenCV REQUIRED)
add_executable(Lulu segmentation.cpp segmentation.h)
target_link_libraries(Lulu ${OpenCV_LIBS})

我创建了一个调试版本,并将参数发送到 cmake: -DCMAKE_BUILD_TYPE=Debug .不过QtCreator还是跳过断点,无法正常启动gdb:

I created a Debug build with argument sent to cmake: -DCMAKE_BUILD_TYPE=Debug . However QtCreator still skip the break points, and can't start gdb properly:

&"warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device
"

如何解决这个问题?

推荐答案

转到 ProjectRun 并在运行设置中选中 Run在终端.它将使 QT Creator 在与 gdb 良好配合的 XTerm(默认)内启动程序并产生 &"warning: GDB: Failed to set control terminal: Inappropriate ioctl for device " 问题走开.

Go to Project, Run and in the run settings check the box that say Run in Terminal. It will make QT Creator launch the program inside a XTerm (default) that plays well with gdb and makes the &"warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device " problem go away.

默认情况下,当启动调试器时,它也会将 QT Creator 带到前台,从而隐藏启动的终端.要停止此行为,请转到:工具选项调试器.在常规选项卡中,取消选中在应用程序中断时将 Qt Creator 置于前台的复选框.

By default, when launching the debugger, it will also bring QT Creator to the foreground and thus hide the terminal that was brought up. To stop this behaviour go to: Tools, Options, Debugger. In the General tab, untick the check box that say Bring Qt Creator to foreground when application interrupts.

如果要更改终端,可以在选项环境中进行.在 System 部分中,将 Terminal 设置为您想要的.对于原生 Ubuntu/Gnome 终端,将其设置为 /usr/bin/gnome-terminal -x.此设置中的参数必须告诉终端执行外部命令或程序.

If you want to change the terminal, you can do so in Options, Environment. In the System section the Terminal to what you want. For native Ubuntu / Gnome terminal, set it to /usr/bin/gnome-terminal -x. The parameters in this setting must tell the terminal to execute an external command or program.

这篇关于使用 QtCreator 设置 GDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆