Summary: Building Python 3.1 on RHEL 5.3 64 bit with --enable-shared
fails to compile all extensions. Building "normal" works fine without any problems.
Please note that this question may seem to blur the line between programming and system administration. However, I believe that because it has to deal directly with getting language support in place, and it very much has to do with supporting the process of programming, that 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. Thank you!
Problem:
Building Python 3.1 on RHEL 5.3 64 bit with --enable-shared
fails to compile all extensions. Building "normal" works fine without any problems.
I can build python 3.1 just fine, but when built as a shared library, it emits many warnings (see below), and refuses to build any of the c
based modules. Despite this failure, I can still build mod_wsgi 3.0c5 against it, and run it under apache. Needless to say, the functionality of Python is greatly reduced...
Interesting to note that Python 3.2a0 (from svn) compiles fine with --enable-shared, and mod_wsgi compiles 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 that this is for is a long-term project, so I'm okay with alpha quality software if needed. Here are some more details on the problem.
Host:
Build:
./configure
./configure --enable-shared
(export CFLAGS="-fPIC"
has been done)
make output
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
Something is wrong with your build environment. It is picking up a libpython3.1.a from /usr/local/lib
; this confuses the error messages. It tries linking with that library, which fails - however, it shouldn't have tried that in the first place, since it should have used the libpython that it just built. I recommend taking the Python 3.1 installation in /usr/local
out of the way.
You don't show in your output whether a libpython3.1.so.1.0 was created in the build tree; it would be important to find out whether it exists, how it was linked, and what symbols it has exported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With