如何在pyenv环境下构建gdb [英] How to build gdb under pyenv environment

查看:127
本文介绍了如何在pyenv环境下构建gdb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pyenv安装的python 2.7.12构建gdb。 Python安装命令为

I'm trying to build gdb with python 2.7.12 installed by pyenv. Python install command was

pyenv install 2.7.12 -k

然后我执行如下命令来构建gdb。

Then I executed commands like below to build gdb.

wget ftp://sourceware.org/pub/gdb/releases/gdb-8.1.tar.gz
tar xvf gdb-8.1.tar.gz
cd gdb-8.1
./configure  --with-python=$(pyenv which python) --prefix=/usr/local CFLAGS="-g -O2 -Wno-string-plus-int"
make

但是失败了,我得到了这些错误。

But it failed and I got these errors.

configure: WARNING: MPFR is missing or unusable; some features may be unavailable.
checking whether to use python... /home/useraccount/.pyenv/versions/2.7.12/bin/python
checking for python2.7... no
configure: error: no usable python found at /home/useraccount/.pyenv/versions/2.7.12/bin/python
Makefile:9096: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory '/tmp/tmp.GE0OV8nAxG/gdb-8.1'
Makefile:849: recipe for target 'all' failed
make: *** [all] Error 2

当我将gdb链接到系统python时,构建命令起作用。

Build commands work when I link gdb to system python.

./configure  --with-python=/usr/bin/python --prefix=/usr/local CFLAGS="-g -O2 -Wno-string-plus-int"
make

我想使用cygdb调试我的cython程序,但是由于这个原因,我无法正常运行cygdb。

I want to use cygdb to debug my cython program but because of this, I cannot run cygdb properly.

任何帮助都会非常有用。

Any help will be very appriciated.


  • Ubuntu 16.04 x64

configure:10391: gcc -o conftest -g -O2 -Wno-string-plus-int  -I/home/useraccount/.pyenv/versions/2.7.12/include/python2.7 -I/home/useraccount/.pyenv/versions/2.7.12/include/python2.7 -static-libstdc++ -static-libgcc  conftest.c -ldl -lncurses -lm -ldl  -L/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic >&5
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:7631: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:7578: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(signalmodule.o): In function `timeval_from_double':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:112: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:113: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:112: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:113: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_abs':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:214: undefined reference to `hypot'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `complex_remainder':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:616: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `complex_divmod':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:642: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_pow':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:143: undefined reference to `hypot'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:144: undefined reference to `pow'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:145: undefined reference to `atan2'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:147: undefined reference to `sincos'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:148: undefined reference to `exp'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:149: undefined reference to `log'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:143: undefined reference to `hypot'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:144: undefined reference to `pow'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:145: undefined reference to `atan2'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:145: undefined reference to `sincos'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_abs':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:214: undefined reference to `hypot'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_is_integer':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:996: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_divmod':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:786: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_rem':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:728: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:728: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_divmod':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:786: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_as_integer_ratio':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1748: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_pow':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:863: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:873: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:922: undefined reference to `pow'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:888: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:898: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `_Py_double_round':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1103: undefined reference to `round'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1142: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1156: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(longobject.o): In function `PyLong_FromString':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/longobject.c:1869: undefined reference to `log'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(dynload_shlib.o): In function `_PyImport_GetDynLoadFunc':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:94: undefined reference to `dlsym'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:130: undefined reference to `dlopen'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:141: undefined reference to `dlsym'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:133: undefined reference to `dlerror'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_start_new_thread':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:194: undefined reference to `pthread_create'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:210: undefined reference to `pthread_detach'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:184: undefined reference to `pthread_attr_setstacksize'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:269: undefined reference to `sem_init'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_free_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:294: undefined reference to `sem_destroy'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:326: undefined reference to `sem_trywait'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `_pythread_pthread_set_stacksize':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:497: undefined reference to `pthread_attr_setstacksize'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:269: undefined reference to `sem_init'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:269: undefined reference to `sem_init'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_forkpty':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:4012: undefined reference to `forkpty'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_openpty':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:3952: undefined reference to `openpty'
collect2: error: ld returned 1 exit status


推荐答案

该错误似乎在 configure 脚本中。特别是以下命令:

The bug appears to be in the configure script. In particular, this command:

gcc -o conftest -g ... conftest.c -ldl -lncurses -lm -ldl  \
  -L/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config \
  -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic

向后( libpython2.7 取决于 libpthread ,因此应在命令行之前。)

is backwards (libpython2.7 depends on libpthread, and so should precede it on the command line).

我检查了 config.log 来自当前的git head,它也有同样的问题。

I checked my config.log from current git head, and it has the same problem.

再来看,GDB运行 python python / python-config.py --ldflags ,当配置 ing时。

Looking further, GDB runs python python/python-config.py --ldflags when configureing.

应用此修补程序:

diff --git a/gdb/python/python-config.py b/gdb/python/python-config.py
index c2b2969c39..0d38ed50c0 100644
--- a/gdb/python/python-config.py
+++ b/gdb/python/python-config.py
@@ -58,12 +58,11 @@ for opt in opt_flags:
         print (to_unix_path(' '.join(flags)))

     elif opt in ('--libs', '--ldflags'):
-        libs = []
+        libs = ['-lpython'+pyver + abiflags]
         if getvar('LIBS') is not None:
             libs.extend(getvar('LIBS').split())
         if getvar('SYSLIBS') is not None:
             libs.extend(getvar('SYSLIBS').split())
-        libs.append('-lpython'+pyver + abiflags)
         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
         # shared library in prefix/lib/.
         if opt == '--ldflags':

并重新运行配置应该可以为您解决此问题。

and re-running configure should fix this for you.

这篇关于如何在pyenv环境下构建gdb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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