问题
I'm trying to compile mod_wsgi (version 3.3), Python 2.6, on a CentOS server - but under virtualenv
, with no success. I'm getting the error:
/usr/bin/ld: /home/python26/lib/libpython2.6.a(node.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/python26/lib/libpython2.6.a: could not read symbols: Bad value
According to the mod_wsgi Installation Issues docs, it could be that the libpython2.6.a file:
- isn't there
- wasn't generated with shared
- was generated for a 32-bit machine, not 64-bit.
Well, the file is in the right place, and readable. I tried to recompile Python 2.6 with the --enable-shared
option, but the entire compilation blew up, with roughly every file giving the same error, that libpython2.6.a was hosed.
I don't know that Python was compiling for 64-bit, but when I ran it, and did:
import platform
print platform.platform()
>>>Linux-2.6.18-028stab070.4-x86_64-with-redhat-5.6-Final
Since Python thinks it's on a x86_64, I would hope that it compiled for 64-bit - if anyone has any way of confirming that, I'd appreciate it.
I tried configuring the mod_wsgi Makefile with both with and without --python=/home/[...]/python2.6, both ways blew up.
I also tried compiling mod_wsgi outside of virtualenv
, using Python 2.4, and it worked fine. Unfortunately, that doesn't help me if I'm going to be using virtualenv
:)
Anyone know how I can get mod_wsgi to compile under virtualenv
?
回答1:
Relevant parts of the documentation are:
http://modwsgi.readthedocs.io/en/develop/user-guides/installation-issues.html#mixing-32-bit-and-64-bit-packages
This mentions the -fPIC problem.
And:
http://modwsgi.readthedocs.io/en/develop/user-guides/installation-issues.html#unable-to-find-python-shared-library
This mentions need to use LD_RUN_PATH when shared library can't be found by mod_wsgi.
Additional information can be found about shared library issues as well as problems with mod_wsgi finding wrong Python installation at:
http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#python-shared-library
回答2:
If you have built Python from sources, add --enable-shared to configure. (It adds -fPIC)
回答3:
You should recompile the libpython2.6.a
with -fPIC
to generate object.
For example:
gcc -fPIC -g -c -Wall xxx.c
来源:https://stackoverflow.com/questions/6116985/problems-compiling-mod-wsgi-in-virtualenv