Search code examples
qtgdbqt-creator

Qt Creator - The selected build of GDB does not support Python scripting


I use a cross-compiled Qt setup on a CentOS host. Developing Qt applications and executing them remotely on the Raspberry Pi works fine. But I got the following error when I try to debug the application:

enter image description here

I use the standard GDB from the official Raspberry Pi toolchain (tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb).

So what is wrong? Why does the GDB needs Python scripting when I use C++?


Solution

  • I usually build GDB from source, so you can configure it to include Python support:

    First some dependencies:

    yum install -y texinfo gcc gcc-c++ make python3-devel wget
    

    Then build and install GDB itself:

    target=arm-linux-gnueabihf
    version=9.1
    
    # Download and extract
    cd /tmp
    [ -e gdb-$version.tar.xz ] || wget https://ftp.gnu.org/gnu/gdb/gdb-$version.tar.xz
    rm -rf gdb-$version
    tar xf gdb-$version.tar.xz
    mkdir -p gdb-$version/build
    cd gdb-$version/build
    
    # Get the Python executable and library directory
    [ -z "${PYTHON}" ] && export PYTHON=python3
    PYTHON_LIBDIR=$("${PYTHON}" -c \
        "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
    
    # Configure GDB
    ../configure \
        --prefix="$HOME/.local" \
        --target=$target \
        --with-python="${PYTHON}" \
        LDFLAGS="-L${PYTHON_LIBDIR}"
    
    # Build and install GDB
    make -j$(nproc)
    make -C gdb install
    

    GDB will be installed in ~/.local/bin, so add it to your path if you haven't already.