Python 3.1.1 with --enable-shared: won't create any extensions

Summary: building Python 3.1 on RHEL 5.3 64 bit with --enable-shared does not compile all extensions. The "normal" structure works fine without problems.

Note that this issue may blur the line between programming and system administration. However, I believe that since it must deal directly with obtaining language support, and it is very important to support the programming process, I would cross-post it here. Also at: https://serverfault.com/questions/73196/python-3-1-1-with-enable-shared-will-not-build-any-extensions . Thanks!

Problem:

Building Python 3.1 on RHEL 5.3 64 bit with --enable-shared cannot compile all extensions. The "normal" structure works fine without problems.

I can create python 3.1 just fine, but when it is created as a shared library, it gives a lot of warnings (see below) and refuses to build any of the modules based on c . Despite this failure, I can still create mod_wsgi 3.0c5 against it and run it under apache. Needless to say, Python functionality has been greatly reduced ...

It is interesting to note that Python 3.2a0 (from svn) compiles fine with -enable-shared, and mod_wsgi compiles a fine against it. But when starting apache, I get:

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

The project for which it is intended is a long-term project, so I am fine with alpha-quality software, if necessary. Here are some details about the problem.

Leading:

  • Dell poweredge
  • Intel Xenon
  • RHEL 5.3 64bit
  • Nothing special "

Build:

  • Python 3.1.1 source distribution
  • Works great with ./configure
  • Doesn't work with ./configure --enable-shared

( export CFLAGS="-fPIC" done)

to conclude


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 
+6
python compilation mod-wsgi
source share
2 answers

Something is wrong with your build environment. It picks up libpython3.1.a from /usr/local/lib ; this confuses error messages. He is trying to link to this library, which does not work - however, she should not have tried it first, since she had to use the libpython she just built. I recommend disabling the installation of Python 3.1 in /usr/local .

You are not showing in your release whether libpython3.1.so.1.0 was created in the assembly tree; it would be important to find out if it exists, how it is connected, and what symbols it exported.

+5
source share

/ usr / local / lib was added to the include path library at compile time:

-L / usr / local / lib -L.

Its common for compilation time to view several "common" paths for libraries (/usr/lib,/usr/local/lib,./ etc.), and also, possibly, collecting / usr / local / lib from a variable environment LD_LIBRARY_PATH and bind it to the build command.

0
source share

All Articles