how do I get python to compile with libz?

喜你入骨 提交于 2019-12-08 08:13:05

问题


the version of python 3.3 I just compiled from source:

$ ldd ./python
    linux-gate.so.1 =>  (0xb776c000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb773b000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7736000)
    libutil.so.1 => /lib/i386-linux-gnu/libutil.so.1 (0xb7731000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb7707000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7589000)
    /lib/ld-linux.so.2 (0xb776d000)

versus my system version of python3 (3.2):

$ ldd `which python3`
    linux-gate.so.1 =>  (0xb7777000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7746000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7741000)
    libutil.so.1 => /lib/i386-linux-gnu/libutil.so.1 (0xb773c000)
    libssl.so.1.0.0 => /lib/i386-linux-gnu/libssl.so.1.0.0 (0xb76ef000)
    libcrypto.so.1.0.0 => /lib/i386-linux-gnu/libcrypto.so.1.0.0 (0xb754b000)
    libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb7536000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb750c000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb738d000)
    /lib/ld-linux.so.2 (0xb7778000)

libz and some other libraries are missing, for some reason. I tried the solution here, but it didn't work. I'm stumped - any ideas?


回答1:


It looks like the answer was in Modules/Setup (and Modules/Setup.dist). Uncommenting line 358 did the trick:

# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz



回答2:


Try using --with-libs. See below.

Python-3.3.0a1/configure --help | grep lib 
.... 
--with-libs='lib1 ...'  link against additional libs
....

After configuring with --with-libs='libz' I see "--with-system-zlib" in config.log. This should be what you're looking for.




回答3:


Just ensure that you install the required libraries before running config and make, e.g.:

yum install sqlite-devel
yum install zlib-devel
yum install openssl-devel

./configure --enable-shared
make install

If you forgot the first time, that's OK, try again. It's a good idea to use --enable-shared if you're going to build other programs that depend on Python later, (e.g. mod_wsgi, required by Django).

If you see "python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory" when running Python, one of the solutions is to simply do:

cp /usr/local/lib/libpython3.5m.so.1.0 /usr/lib64/

Otherwise add it to the LD_LIBRARY_PATH.



来源:https://stackoverflow.com/questions/9764692/how-do-i-get-python-to-compile-with-libz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!