11-29杂记

源码安装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 value
collect2: 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 local
symbol' 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 value
collect2: ld returned 1 exit status
apxs: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 一切顺利

困扰了一天的问题终于解决,可以进行下一步了

你可能感兴趣的:(python,object,Debian,library,X86,symlink)