How to stop zlib from killing python

Jeremy Hylton jeremy at cnri.reston.va.us
Tue Oct 26 17:14:10 EDT 1999


>>>>> "S" == sessile  <sessile at in-gen.net> writes:

  S> zlib zlibmodule.c -I/home/me/include -L/home/me/lib -lz

  S> Python's 'make' completes without error.  However, when I execute
  S> the newly generated python, I get:

  S> % python ld.so.1: python: fatal: libz.so.1.1.3: open failed: No
  S> such file or directory Killed

  S> Why can't python find the library at runtime? (yes, my C
  S> programming experience is minimal)

When you are building Python, I presume you are not building with
extensions as shared libraries, i.e. the *shared* line in your Setup
file is not commented out.  (This is a perfectly sensible thing to
do.)

The problem is that the zlib extension requires the libz.so shared
library, but when you run Python it can't be found.  There are two
solutions: 

1. Add the directory that contains libz.so (presumably /home/me/lib)
to your LD_LIBRARY_PATH environment variable.  In bash:
# export LD_LIBRARY_PATH=/home/me/lib

2. Change your setup line from
   zlib zlibmodule.c -I/home/me/include -L/home/me/lib -lz
to
   zlib zlibmodule.c -I/home/me/include /home/me/lib/libz.a

The latter will include a copy of libz.a in your binary instead of
just a reference to your shared library.

Jeremy






More information about the Python-list mailing list