develooper Front page | perl.perl5.porters | Postings from October 2003

How to tell CPAN modules about static libs

From:
Martin MOKREJŠ
Date:
October 1, 2003 02:39
Subject:
How to tell CPAN modules about static libs
Message ID:
Pine.OSF.4.51.0310011109300.292159@tao.natur.cuni.cz
Hi,
  I can get perl-5.8.1 compiled dynamically but with statically linked -ldb
and -lgdbm on Tru64Unix 5.1A. It seems the trick is to edit config.sh and
ext.libs. Unfortunately, perl cannot be relinked when later module installation
requires relinking. I'm not suire it that's a problem with perl or with
CPAN modules not able to fetch from perl it's original ldflags/libs/perlibs.

In config.sh I have:

ldflags=' -L/software/@sys/usr/lib -L/software/@sys/usr/BerkeleyDB-3.3.11/lib -L/usr/local2/lib -I/software/@sys/usr/include -I/software/@sys/usr/BerkeleyDB-3.3.11/include -I/usr/local2/include'
ldflags_uselargefiles=''
ldlibpthname='LD_LIBRARY_PATH'
less='less'
lib_ext='.a'
libc='/usr/shlib/libc.so'
libperl='libperl.a'
libpth='/software/@sys/usr/lib /software/@sys/usr/BerkeleyDB-3.3.11/lib /usr/local2/lib /usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/
lib /usr/local/lib /var/shlib'
libs='/software/@sys/usr/BerkeleyDB-3.3.11/lib/libdb.a /software/@sys/usr/lib/libgdbm.a /usr/ccs/lib/libdbm.a -lm -lutil -lpthread -lexc
'
libsdirs=' /software/@sys/usr/lib /usr/ccs/lib /usr/local2/lib /usr/shlib'
libsfiles=' libgdbm.a libdbm.a libdb.a libm.so libutil.a libpthread.so libexc.so'
libsfound=' /software/@sys/usr/BerkeleyDB-3.3.11/lib/libdb.a /software/@sys/usr/lib/libgdbm.a /usr/ccs/lib/libdbm.a /usr/shlib/libm.so libutil.a /usr/shlib/libpthread.so /usr/shlib/libexc.so'
libspath=' /software/@sys/usr/lib /software/@sys/usr/BerkeleyDB-3.3.11/lib /usr/local2/lib /usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib'
libswanted='sfio socket bind inet nsl nm gdbm dbm db malloc dld ld sun m crypt sec util cposix posix ucb BSD pthread exc'
libswanted_uselargefiles=''
[cut]
locincpth='/software/@sys/usr/include /software/@sys/usr/BerkeleyDB-3.3.11/include /usr/local2/include'
loclibpth='/software/@sys/usr/lib /software/@sys/usr/BerkeleyDB-3.3.11/lib /usr/local2/lib'
[cut]
perllibs='/software/@sys/usr/BerkeleyDB-3.3.11/lib/libdb.a /software/@sys/usr/lib/libgdbm.a /usr/ccs/lib/libdbm.a -lm -lutil -lpthread -lexc'
perlpath='/software/@sys/usr/bin/perl'
[cut]
# Configure command line arguments.
config_arg0='Configure'
config_args='-Dlocincpth=/software/@sys/usr/include /software/@sys/usr/BerkeleyDB-3.3.11/include /usr/local2/include -Dloclibpth=/software/@sys/usr/lib /software/@sys/usr/BerkeleyDB-3.3.11/lib /usr/local2/lib -Doptimize=-O3 -arch ev56 -Accflags= -Aldflags=-L/software/@sys/usr/lib -L/software/@sys/usr/BerkeleyDB-3.3.11/lib -L/usr/local2/lib -I/software/@sys/usr/include -I/software/@sys/usr/BerkeleyDB-3.3.11/include -I/usr/local2/include -Dprefix=/software/@sys/usr -Duselongdouble -Uusedl -Ushrplib -Duseithreads'
config_argc=10
config_arg1='-Dlocincpth=/software/@sys/usr/include /software/@sys/usr/BerkeleyDB-3.3.11/include /usr/local2/include'
config_arg2='-Dloclibpth=/software/@sys/usr/lib /software/@sys/usr/BerkeleyDB-3.3.11/lib /usr/local2/lib'
config_arg3='-Doptimize=-O3 -arch ev56'
config_arg4='-Accflags='
config_arg5='-Aldflags=-L/software/@sys/usr/lib -L/software/@sys/usr/BerkeleyDB-3.3.11/lib -L/usr/local2/lib -I/software/@sys/usr/include -I/software/@sys/usr/BerkeleyDB-3.3.11/include -I/usr/local2/include'
config_arg6='-Dprefix=/software/@sys/usr'
config_arg7='-Duselongdouble'
config_arg8='-Uusedl'
config_arg9='-Ushrplib'
config_arg10='-Duseithreads'

From ext.libs I had to manually remove -ldb -lgdbm. Why are they present at all?


The real problem here ... When perl is relinked later, it often fails like:
[cut]
sf-thread-multi-ld/auto/Data/Dumper/Dumper.a /afs/gsf.de/alpha_dux51/usr/lib/perl5/5.8.1/alpha-dec_osf-thread-multi-ld/auto/DB_File/DB_File.a /afs/gsf.de/alpha_dux51/usr/lib/perl5/5.8.1/alpha-dec_osf-thread-multi-ld/auto/Cwd/Cwd.a /afs/gsf.de/alpha_dux51/usr/lib/perl5/5.8.1/alpha-dec_osf-thread-multi-ld/auto/ByteLoader/ByteLoader.a /afs/gsf.de/alpha_dux51/usr/lib/perl5/5.8.1/alpha-dec_osf-thread-multi-ld/auto/B/C/C.a /afs/gsf.de/alpha_dux51/usr/lib/perl5/5.8.1/alpha-dec_osf-thread-multi-ld/auto/B/B.a /software/@sys/usr/lib/perl5/5.8.1/alpha-dec_osf-thread-multi-ld/CORE/libperl.a `cat blib/arch/auto/Term/ReadKey/extralibs.all` /software/@sys/usr/BerkeleyDB-3.3.11/lib/libdb.a /software/@sys/usr/lib/libgdbm.a /usr/ccs/lib/libdbm.a -lm -lutil -lpthread -lexc
To install the new "perl" binary, call
    make -f Makefile.aperl inst_perl MAP_TARGET=perl
To remove the intermediate files say
    make -f Makefile.aperl map_clean
make[1]: Leaving directory `/usr/local/scratch/.cpan/build/TermReadKey-2.21'
PERL_DL_NONLAZY=1 ./perl "-Iblib/lib" "-Iblib/arch" -w test.pl
237018:./perl: /sbin/loader: Fatal Error: Cannot map library libdb-3.3.so
make: *** [test_static] Error 1
  /software/@sys/usr/bin/make test -- NOT OK

  I think the problem is in this example with TermReadKey-2.21/blib/arch/auto/Term/ReadKey/extralibs.all,
where is blindly specified that -ldb -lgdbm should be used. Where does this
requirement come from? Please note that my perl binary is already linked against
static libdb.a and libgdbm.a and works.

  I'm asking on this list as this happens with many other packages(i.e. when their
installation requires relinking perl, the link step fails). I really do not want to
change LD_LIBRARY_PATH on all systems, sometimes it's even impossible because of
security checks in sshd, apache, or singleuser mode etc.
  My goal is to have linked in dynamically only those libs provides by vendor,
and as the system wide libdb.so is outdated and version 1, I don't want to use that.
We cannot take rid of that, because -lsecurity(something like -lpam) requires
that *vendor* provided -ldb and checks for it's version number "osf", so
I cannot just replace /usr/lil/libdb.so with something newer.

-- 
Martin Mokrejs <mmokrejs@natur.cuni.cz>, <m.mokrejs@gsf.de>
PGP5.0i key is at http://www.natur.cuni.cz/~mmokrejs
MIPS / Institute for Bioinformatics <http://mips.gsf.de>
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1, D-85764 Neuherberg, Germany
tel.: +49-89-3187 3683 , fax: +49-89-3187 3585



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About