building Python from source with zlib support

后端 未结 10 776
广开言路
广开言路 2020-11-28 04:18

When building Python 3.2.3 from source on Ubuntu 12.04, the zlib module is not available.

I downloaded the official source distribution from python.org, and attempte

10条回答
  •  醉酒成梦
    2020-11-28 04:50

    For anyone who's trying to use a non-system / non-standard zlib (e.g. building your own from source), make sure to pass both CPPFLAGS (not CFLAGS!) and LDFLAGS to ./configure. For example, if your zlib is in /opt/zlib:

    ./configure CPPFLAGS='-I/opt/zlib/include' LDFLAGS='-L/opt/zlib/lib'
    make
    sudo make install
    

    I ended up going down the rabbit hole trying to figure out why our Python wasn't building with zlib support and found out that the CPython setup.py does not look at CFLAGS for include dirs, only CPPFLAGS: https://github.com/python/cpython/blob/master/setup.py#L562

提交回复
热议问题