statically linking the entire runtime (HPUX Python2.1)

cmkl cmkleffner at gmx.de
Mon Jun 18 11:32:18 EDT 2001


Carsten Gaebler <clpy at snakefarm.org> wrote in message news:<3B2B18A3.E7CE525C at snakefarm.org>...
> Andrew MacIntyre wrote:
>  
> > On Fri, 15 Jun 2001, Carsten Gaebler wrote:
> > 
> > > I noticed that you can't build the curses module statically. The linker
> > > then complains about duplicate definitions of 'tputs' in libncurses and
> > > libtermcap. Is there a way to get around this?
> > 
> > Do you really need to link in libtermcap??  I had been under the
> > impression that libncurses contained all necessary functionality.
> 
> You're right, the curses module does not need libtermcap. The problem
> actually was that I put the following into Modules/Setup:
> 
> readline readline.c /usr/lib/libreadline.a /usr/lib/libtermcap.a
> _curses _cursesmodule.c /usr/lib/libncurses.a
> 
> So I had a conflicting libtermcap from the readline module which does
> not need libtermcap either. After deleting that and replacing
> 
> LIBS=          -lpthread -ldl  -lutil
> LIBM=          -lm
> 
> by
> 
> LIBS= /usr/lib/libpthread.a /usr/lib/libdl.a /usr/lib/libutil.a
> LIBM= /usr/lib/libm.a
> 
> in the Makefile, I now have a 5.3 megs python interpreter that depends
> on no more than ld.so and libc.so. :-)
> Well, you could probably also say:
> 
> LIBC=/usr/lib/libc.a
> 
> but that would be like Monster Truck Madness ... ;-)
> 
> 
> cg.

Hi,

I have now sucessfully build a static python2.1 version on HP-UX11 with cc:

1) edit configure and change: '-lpthread' to '/usr/lib/libpthread.a'
   if you want to have the pthread libary static.

   For HP-UX10 you may add '+Onolimit +DAportable' to the compiler switches.

2) change Modules/Setup to build all libraries there:

my Setup contains the following modules:

*static*
posix posixmodule.c             # posix (UNIX) system calls
_sre _sre.c                     # Fredrik Lundh's new regular expressions
array arraymodule.c             # array objects
cmath cmathmodule.c       # -lm # complex math library functions
math mathmodule.c         # -lm # math library functions, e.g. sin()
struct structmodule.c           # binary structure packing/unpacking
time timemodule.c         # -lm # time operations and variables
operator operator.c             # operator.add() and similar goodies
_weakref _weakref.c             # basic weak reference support
_codecs _codecsmodule.c         # access to the builtin codecs and codec registry
_testcapi _testcapimodule.c     # Python C API test module
_symtable symtablemodule.c
strop stropmodule.c
regex regexmodule.c regexpr.c
pcre pcremodule.c pypcre.c
unicodedata unicodedata.c       # static Unicode character database
_locale _localemodule.c         # access to ISO C locale support
fcntl fcntlmodule.c             # fcntl(2) and ioctl(2)
pwd pwdmodule.c                 # pwd(3)
grp grpmodule.c                 # grp(3)
errno errnomodule.c             # posix (UNIX) errno values
select selectmodule.c           # select(2); not on ancient System V
mmap mmapmodule.c
xreadlines xreadlinesmodule.c
_socket socketmodule.c
crypt cryptmodule.c # -lcrypt   # crypt(3); needs -lcrypt on some systems
nis nismodule.c -lnsl           # Sun yellow pages -- not everywhere
termios termios.c               # Steen Lumholt's termios module
resource resource.c             # Jeremy Hylton's rlimit interface
audioop audioop.c               # Operations on audio samples
imageop imageop.c               # Operations on images
rgbimg rgbimgmodule.c           # Read SGI RGB image files (but coded portably)
md5 md5module.c md5c.c
sha shamodule.c
timing timingmodule.c
rotor rotormodule.c             # enigma-inspired encryption
syslog syslogmodule.c           # syslog daemon interface
_curses _cursesmodule.c -lcur_colr -ltermcap
new newmodule.c
dbm dbmmodule.c                 # dbm(3) may require -lndbm or similar
binascii binascii.c
parser parsermodule.c
cStringIO cStringIO.c
cPickle cPickle.c
fpectl fpectlmodule.c  -lcl                                                    

some patches are required in: _cursesmodule.c, termios.c, py_curses.h

the curses module is linked against libcur_colr NOT libcurses !
py_curses.h has to include:     #include <curses_colr/curses.h>
_cursemodule.c has to include:  #define STRICT_SYSV_CURSES
I have no idea what to do with ncurses (I dont't have it)

termios.c compiles if you exclude the relevant macros VREPRINT ...
          (see the error list)

3) ./configure --prefix=/somewhere --without-gcc

4) make, make test, make install

python is linked against: (> chatr python )

dynamic   /usr/lib/libnsl.1
dynamic   /usr/lib/libdld.2
dynamic   /usr/lib/libcur_colr.1
dynamic   /usr/lib/libcl.2           (only needed by fpectl)
dynamic   /usr/lib/libm.2
dynamic   /usr/lib/libc.2

these libraries should be available on other HPUX11 systems.
python size is "only" 1.8 Mbyte

A minimal 'freezed' python script is about 1.0 Mbyte (stripped)
This is useful for my needs.

comments ?

Sincerly

Carl



More information about the Python-list mailing list