Setup GDB with QtCreator

14,544

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\n" problem go away.

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.

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.

Share:
14,544
Dzung Nguyen
Author by

Dzung Nguyen

Love hacking!!

Updated on June 01, 2022

Comments

  • Dzung Nguyen
    Dzung Nguyen almost 2 years

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

    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})
    

    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\n"
    

    How to fix this problem?