Qt Creator - 所选的 GDB 构建不支持 Python 脚本

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

我在 CentOS 主机上使用交叉编译的 Qt 设置。开发 Qt 应用程序并在 Raspberry Pi 上远程执行它们工作正常。但是当我尝试调试应用程序时出现以下错误:

我使用官方的标准GDB Raspberry Pi toolchain (tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb).

所以怎么了?为什么我使用 C++ 时 GDB 需要 Python 脚本?

我通常从源代码构建 GDB,因此您可以将其配置为包含 Python 支持:

首先是一些依赖项:

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

然后构建并安装 GDB 本身:

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 将安装在 ~/.local/bin 中,如果您还没有将其添加到您的路径中。

您可以在您的终端中运行这个命令来安装gdb

sudo apt-get install gdb