Getting expat compiled properly

Mats Wichmann mats at laplaza.org
Wed Sep 5 05:57:02 EDT 2001


On Wed, 5 Sep 2001 06:55:54 +0200, "Magnus Lie Hetland"
<mlh at idi.ntnu.no> wrote:

:"Martin von Loewis" <loewis at informatik.hu-berlin.de> wrote in message
:news:j4lmjvme2q.fsf at informatik.hu-berlin.de...
:> "Magnus Lie Hetland" <mlh at idi.ntnu.no> writes:
:>
:> > I have managed to compile expat so it works with
:> > Python (2.2a1), but when I try to run cgi scripts now,
:> > they don't work. The reason is that Python can't
:> > find libexpat.so ...
:>
:> You didn't mention what operating system you are using;
:
:Ah... Sorry. Solaris. (SunOS 5.8)
:
:> most likely,
:> setting LD_LIBRARY_PATH would work around this problem?
:
:The problem is that I'm not an administrator at this machine, so
:it would be a bit awkward... I guess I could take the #!/usr/bin/env
:trick to new heights, but...

You're limited to one argument...  

:> On Linux,
:> adding the path containing libexpat.so into /etc/ld.so.conf would also
:> help.
:
:Again not an option.

This is a little tricky, yes.  You're trying to enable software where
you can't control the entire execution context.

:> > I thought this was supposed to be a static link (with libexpat.a)?
:>
:> What made you think so? In the presence of both a static and a dynamic
:> library, all linkers I know will prefer the dynamic one (unless you
:> tell them otherwise).
:
:But it _doesn't_ find a dynamic one... That's why it doesn't work...
:And if libexpat were statically linked (as described in the Modules/Setup
:files), it shouldn't fret, should it?

You problem is the link editor (ld) is finding a dynamic libexpat, but
the dynamic linker is not.  Since you don't appear to be able to
control the environment in which the dynamic linker runs, you have to
have a discussion with the link editor :-) ... linking in the static
libexapt should resolve the problem.

As a hack:

build Python, capturing the output. grab the link-edit line, put it in
a script by itself, and modify where it says "-lexpat" replacing that
one argument word with the path to the static expat library.

If that works you can work on tweaking the Python build.  Not knowing
which compiler you're using I can't give you exact syntax, but there's
a way to temporarily turn off the search for a dynamic library, so
that your command line will (conceptually) look like this:

......  -StopLookingForDynamicLibs -lexpat -StartLookingForDynamicLibs
.....

e.g., just for expat, search only for a static copy, then go back to
looking for dynamic in preferece to static.


Mats Wichmann




More information about the Python-list mailing list