7

摘要:在 RHEL 5.3 64 位上构建 Python 3.1--enable-shared无法编译所有扩展。建立“正常”工作正常,没有任何问题。

请注意,这个问题似乎模糊了编程和系统管理之间的界限。但是,我相信因为它必须直接处理获得语言支持,并且与支持编程过程有很大关系,所以我会在这里交叉发布。也在:https ://serverfault.com/questions/73196/python-3-1-1-with-enable-shared-will-not-build-any-extensions 。谢谢!

问题:

在 RHEL 5.3 64 位上构建 Python 3.1--enable-shared无法编译所有扩展。建立“正常”工作正常,没有任何问题。

我可以很好地构建 python 3.1,但是当构建为共享库时,它会发出许多警告(见下文),并拒绝构建任何c基于模块的模块。尽管失败了,我仍然可以针对它构建 mod_wsgi 3.0c5,并在 apache 下运行它。不用说,Python的功能大大减少了……

有趣的是,Python 3.2a0(来自 svn)使用 --enable-shared 可以很好地编译,而 mod_wsgi 可以很好地针对它进行编译。但是当启动 apache 时,我得到:

Cannot load /etc/httpd/modules/mod_wsgi.so into server: /etc/httpd/modules/mod_wsgi.so: undefined symbol: PyCObject_FromVoidPtr

这是一个长期项目,所以如果需要,我可以使用 alpha 质量软件。以下是有关该问题的更多详细信息。

主持人:

  • 戴尔 PowerEdge
  • 英特尔氙气
  • RHEL 5.3 64 位
  • 没什么特别的”

建造:

  • Python 3.1.1 源代码分发
  • ./configure
  • 不能正常工作./configure --enable-shared

export CFLAGS="-fPIC"已经完成)

输出


gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -fPIC -DPy_BUILD_CORE -c ./Modules/_weakref.c -o Modules/_weakref.o


building 'bz2' extension gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I./Include -I/usr/local/include -IInclude -I/home/build/RPMBUILD/BUILD/Python-3.1.1 -c /home/build/RPMBUILD/BUILD/Python-3.1.1/Modules/bz2module.c -o build/temp.linux-x86_64-3.1/home/build/RPMBUILD/BUILD/Python-3.1.1/Modules/bz2module.o gcc -pthread -shared -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes build/temp.linux-x86_64-3.1/home/build/RPMBUILD/BUILD/Python-3.1.1/Modules/bz2module.o -L/usr/local/lib -L. -lbz2 -lpython3.1 -o build/lib.linux-x86_64-3.1/bz2.so /usr/bin/ld: /usr/local/lib/libpython3.1.a(abstract.o): relocation R_X86_64_32 against 'a local symbol' can not be used when making a shared object; recompile with -fPIC


Failed to build these modules:
_bisect            _codecs_cn         _codecs_hk
_codecs_iso2022    _codecs_jp         _codecs_kr
_codecs_tw         _collections       _csv
_ctypes            _ctypes_test       _curses
_curses_panel      _dbm               _elementtree
_gdbm              _hashlib           _heapq
_json              _lsprof            _multibytecodec
_multiprocessing   _pickle            _random
_socket            _sqlite3           _ssl
_struct            _testcapi          array
atexit             audioop            binascii
bz2                cmath              crypt
datetime           fcntl              grp
itertools          math               mmap
nis                operator           ossaudiodev
parser             pyexpat            readline
resource           select             spwd
syslog             termios            time
unicodedata        zlib
4

2 回答 2

6

您的构建环境有问题。它正在从以下位置获取 libpython3.1.a /usr/local/lib;这会混淆错误消息。它尝试与该库链接,但失败了 - 但是,它不应该首先尝试这样做,因为它应该使用它刚刚构建的 libpython。我建议不要安装 Python 3.1 /usr/local

您没有在输出中显示是否在构建树中创建了 libpython3.1.so.1.0;找出它是否存在、它是如何链接的以及它导出了哪些符号非常重要。

于 2009-10-10T08:01:32.463 回答
0

/usr/local/lib 已在编译时添加到库包含路径中:

-L/usr/local/lib -L.

编译时通常会在多个“公共”路径中查找库(/usr/lib、/usr/local/lib、./ 等),但也可能从环境变量中获取 /usr/local/lib LD_LIBRARY_PATH 并将其附加到构建命令中。

于 2009-10-11T04:10:17.127 回答