[英]Building gdb 10.1 from source with custom python
我正在嘗試從源代碼構建最新的 gdb 10.1。
[我想要這樣做的原因是我正在嘗試調試一個鏈接到 Python 2.7.18 自定義構建的程序,並且我的系統 gdb 鏈接到我的 /lib64 目錄中的 Python 2.7.5 構建,並且不適用於較新版本]。
通讀自述文件后,我已使用以下方法進行配置:
../gdb-10.1/configure --with-python=<path to my 2.7.18 installation> --prefix=<path to where I want the new gdb to go>
...然后運行
make all install
...按照說明。 但是,每次構建嘗試都會失敗,並出現一系列以下形式的錯誤消息:
python/py-arch.o: In function `gdbarch_to_arch_object(gdbarch*)':
.../build/gdb/../../../gdb-10.1/gdb/python/py-arch.c:86: undefined reference to `_Py_RefTotal'
python/py-arch.o: In function `gdbpy_ref_policy<_object>::decref(_object*)':
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_NegativeRefcount'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_Dealloc'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_NegativeRefcount'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_Dealloc'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_Dealloc'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_NegativeRefcount'
在檢查配置步驟的輸出和 Makefile 本身時,我根本找不到我在配置時指定的 Python 安裝的任何參考(並且我也將其放置在 LD_LIBRARY_PATH 的開頭以確保編譯器並且鏈接器可以在構建時找到它)。
我在這里缺少什么?
我最近做了類似的事情,也很掙扎,盡管是針對不同的問題。
我懷疑您的構建問題可能與您使用 LD_LIBRARY_PATH 或來自您的環境(PATH、CFLAGS、LDFLAGS 等)的其他內容有關。 您不應該在構建期間設置這些。
這是我所做的概述:
(1)對於gdb的構建,我使用了這樣的方法:
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
unset LD_LIBRARY_PATH
../gdb-10.1/configure --prefix=/opt/gdb-10.1 --with-python=/opt/conda-py2.7.18
make &> make.log
make install &> make-install.log
PATH 的設置和 LD_LIBRARY_PATH 的未設置旨在凈化環境。 這確保構建只能使用--with-python
來定位 python (它本身在bin/python
,在 python 前綴下)。 (CFLAGS 和 LDFLAGS 也沒有設置,也沒有設置任何 PYTHON 變量。)
我保留了 make 階段的輸出。 如果您查看那里,您應該會看到with-python
選項被選中。
這一切都很好。
(2) 要調用調試器(並在 /opt 下使用我的 python),我需要一個額外的步驟:設置 LD_LIBRARY_PATH 以便使用我的 pythons libpython:
export LD_LIBRARY_PATH=/opt/conda-py2.7.18/lib
/opt/gdb-10.1/bin/gdb
(gdb) python import sys; print(sys.version)
2.7.18 | Anaconda, Inc.
找到一種方法來避免這種設置 LD_LIBRARY_PATH 的需要會很好; 這可能需要靜態鏈接 libpython,或引入一些構建標志,例如,使用 rpath。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.