交叉编译GDB时出现Python丢失或无法使用的错误

问题描述 投票:0回答:8

我在尝试交叉编译 GDB 时收到此错误(使用

--with-python
标志):

checking for python: /usr/bin/python
checking for python2.7: no
configure: error: python is missing or unusable

我确保在

/usr/bin
中安装了python2.7。我什至删除了软件包并重新安装了它。我尝试使用
--with-python=/usr/bin
--with-python=/usr/local
,但没有运气。我确信 2.7 已经安装了。知道该怎么做吗?

python gdb
8个回答
22
投票

我在 Debian 6.0 上编译 GDB 7.4.1 时遇到了同样的问题

解决方案是安装 python headers

sudo apt-get install python2.6-dev

然后使用正确的标志进行配置

./configure --with-python

14
投票

我在 gdb 7.4 上也遇到了同样的问题,花了一些时间调试后终于让它工作了。

通过检查文件

<gdb-source-path>/gdb/config.log
,你会注意到一行:

configure:11031: gcc -o conftest -g -O2   -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7   conftest.c -lncurses -lz -lm    -L/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -ldl -framework CoreFoundation -lpython2.7 -u _PyMac_Error Python.framework/Versions/2.7/Python >&5

似乎脚本

python/python-config.py
返回了一些无效标志,导致
gcc
命令失败。

解决办法是打开

<gdb-source-directory>/gdb/python/python-config.py
,注释掉这两行:

#            if getvar('LINKFORSHARED') is not None:
#                libs.extend(getvar('LINKFORSHARED').split())

8
投票

我刚刚在使用 Continuum 的 Python 2.7 构建 gdb 7.8.1 时遇到了类似的问题,就我而言,它安装在非标准位置。

在这种情况下,解决方案是在运行“configure”之前提供额外的配置:

export LDFLAGS="-Wl,-rpath,<non-standard-Python-lib-location> -L<non-standard-Python-lib-location>"
configure --with-python=<non-standard-Python-executable-location>

7
投票

我在构建 ESP8266 SDK 时遇到了此错误。刚刚做了一个 sudo apt-get install python-dev 现在可以了。


1
投票

只是添加我自己的解决方案,因为我在这里看不到它。就我而言,我可以通过使用

configure
来解决此问题,如下所示:

./configure --with-python=/usr/bin/python3

这是在 Ubuntu 22.04 机器上。我怀疑

--with-python
需要现有 python 二进制文件的完整路径,因此这对于标准发行版来说似乎是一个更简单的解决方案。


1
投票

经过多次尝试,我成功在我的 ubuntu 22.04 上安装了 gdb 13.1

 sudo apt-get install python3-dev

./configure --with-python=/usr/bin/python3

0
投票

我在使用 python 3.8 构建 gdb 13.0.50 以获得更新的 udpate 时遇到了几乎相同的错误。在

./configure --with-python
之后运行 make 会显示 python 缺失错误。 在编译过程中,它似乎在寻找 python 3.8 的
usr/bin/python
,而我们只有
usr/bin/python3

于是我迅速将python目录的名称从

usr/bin/python3
更改为
usr/bin/python
并且编译并成功找到python。

不要忘记将其改回依赖项


0
投票
csh: setenv LIBRARY_PATH /path/to/python/lib:$LIBRARY_PATH 
bash: export LIBRARY_PATH=/path/to/python/lib:$LIBRARY_PATH 

并且 LD_LIBRARY_PATH 对 gdb 编译没有任何帮助。 (用python-3.8编译gdb-9.2)

© www.soinside.com 2019 - 2024. All rights reserved.