11-29雜記

來源:互聯網
上載者:User
源碼安裝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 一切順利

困擾了一天的問題終於解決,可以進行下一步了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.