Static executable with shared modules

Rickard Lind rickard.lind at ntier.se
Mon Jan 17 04:49:55 EST 2005


Martin v. Löwis wrote:
 > I'm not what "build statically" means; if you talking about
 > building a statically linked interpreter binary - then no,
 > this is not possible. At a minimum, you need to link with -ldl,
 > or else you cannot perform dlopen(3).

I'll be more specific: when I build python 2.3.4 on FreeBSD 4.9,
the interpreter binary is linked against three shared libraries: 
libutil.so.3, libm.so.2 and libc_r.so.4. Now, these libraries are
not present on the TARGET system (which is distinct from the build
system, but based on the same version of FreeBSD) so I add "-static"
to LDFLAGS. This produces an interpreter that runs on the target
system (no dependency on shared libc etc) but it also cannot load
modules compiled as shared libraries. Man page for dlopen(3) says
it is located in libc (and consquently there seems to be no libdl),
and anyway I'd expect to get a link error if the dl* functions were
not present. What I DO get is an ImportError exception.

At present I see no other option than to link the modules into the
interpreter which is very inconvenient since I'll have to rebuild
the every time a module changes :-(

/r



More information about the Python-list mailing list