源碼安裝mod_wsgi出現如下問題:/usr/bin/ld: .../lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against 'a local symbol' can not be used when making a shared object; recompile with -fPIC.../lib/libpython2.7.a: could not read symbols: Bad valuecollect2: ld returned 1 exit status
網上有很多介紹該問題的解決方案:http://www.cbug.org/2011/11/21/multiple-python-versions-cause-shared-library-mess.html#more-85 介紹的最為詳細,不料一一試之,問題依然存在!
最後在modwsgi官網http://code.google.com/p/modwsgi/wiki/InstallationIssues發現如下:
When attempting to compile mod_wsgi on a Linux system using an X86 64 bit processor, the following error message can arise:
/bin/sh /usr/lib64/apr/build/libtool --silent --mode=link gcc -o \ mod_wsgi.la -I/usr/local/include/python2.4 -DNDEBUG -rpath \ /usr/lib64/httpd/modules -module -avoid-version mod_wsgi.lo \ -L/usr/local/lib/python2.4/config -lpython2.4 -lpthread -ldl -lutil/usr/bin/ld: /usr/local/lib/python2.4/config/libpython2.4.a(abstract.o): relocation R_X86_64_32 against `a localsymbol' can not be used when making a shared object; recompile with -fPIC/usr/local/lib/python2.4/config/libpython2.4.a: could not read symbols: Bad valuecollect2: ld returned 1 exit statusapxs:Error: Command failed with rc=65536.make: *** [mod_wsgi.la] Error 1
This error is believed to be result of the version of Python being used having been originally compiled for the generic X86 32 bit architecture whereas mod_wsgi is being compiled for X86 64 bit architecture. The actual error arises
in this case because 'libtool' would appear to be unable to generate a dynamically loadable module for the X86 64 bit architecture from a X86 32 bit static library. Alternatively, the problem is due to 'libtool' on this platform not being able to create a
loadable module from a X86 64 bit static library in all cases.
If the first issue, the only solution to this problem is to recompile Python for the X86 64 bit architecture. When doing this, it is preferable, and may actually be necessary, to ensure that the '--enable-shared' option is provided
to the 'configure' script for Python when it is being compiled and installed.
If rebuilding Python to generate a shared library, do make sure that the Python shared library, or a symlink to it appears in the Python 'config' directory of your Python installation. If the shared library doesn't appear here
next to the static version of the library, 'libtool' will not be able to find it and will still use the static version of the library. It is understood that the Python build process may not actually do this, so you may have to do it by hand.
If the version of Python being used was compiled for X86 64 bit architecture and a shared library does exist, but not in the 'config' directory, then adding the missing symlink may be all that is required.
簡單翻譯之就是說如果遇到此問題,將python重新編譯(以x86 64位靜態庫),即./configure時加上 --enable shared
之後編譯mod_wsgi會出現如下問題:
error while loading shared libraries: libpython2.6.so.1.0: \ cannot open shared object file: No such file or directory
解決方案很簡單:(debian系統)
# echo "/usr/local/lib" >> /etc/ld.so.conf# ldconfig
其他系統具體詳見:http://hi.baidu.com/susuper_/blog/item/b1a3af012ea741326a60fbfb.html
至此編譯mod_wsgi,正常,make&&make install 一切順利
困擾了一天的問題終於解決,可以進行下一步了