It is very difficult to remove any lib shared library dependencies on solaris. While compiling the RPM sources on Solaris I wished to ensure my resulting executable was not dependent on there being a libz or berkeley DB installed on the system. One of my problems in compiling this was the lack of options in libtool for this task. (Other bug tickets are being opended with ld and automake which caused other 'obvious' solutions to not work as well) I wanted to include two libraries (/usr/lib/libz.a /usr/local/lib/libdb-3.1.a) in my executable because I did not want my executable to depend on those libraries. The obvious thing to try is to put the known libraries (with the .a extension) on the command line. I will need to be able to include a handful of libraries in my binaries from time to time. It will not always be possible to have .la files for every archive I wish to include in my binary. 1) I can not put them on the libtool link line, because that is an error: res03$ /bin/sh ./libtool --mode=link gcc -Wall -O2 -o libpopt.la -rpath /usr/local/lib popt.lo findme.lo poptparse.lo poptconfig.lo popthelp.lo -L/usr/ucblib -R /usr/ucblib /usr/lib/libz.a /usr/local/lib/libdb-3.1.a libtool: link: cannot build libtool library `libpopt.la' from non-libtool objects: /usr/lib/libz.a /usr/local/lib/libdb-3.1.a I was unable to use the libtool flags: `-all-static', `-static' because there are not fully static binaries on solaris so my linker died. I really wanted '-static' to adjust the search path ld uses to find .a files before .so file. Instead it forces the result of the link to be a static binary which is impossible on solaris. 2) If I add '-all-static' to LDFLAGS I get an error: make LDFLAGS="-all-static" /bin/sh ../libtool --mode=link gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -all-static -o dump dump.o ../build/librpmbuild.la ../lib/librpm.la ../rpmio/librpmio.la ../popt/libpopt.la mkdir .libs gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -static -o dump dump.o ../build/.libs/librpmbuild.a ../lib/.libs/librpm.a -ldb-3.1 ../rpmio/.libs/librpmio.a -L/usr/local/lib -L/usr/ucblib -lnsl -lsocket -lz ../popt/.libs/libpopt.a -R/usr/local/lib -R/usr/ucblib -R/usr/local/lib -R/usr/ucblib Undefined first referenced symbol in file dlclose /usr/lib/libnsl.a(netdir.o) stpcpy ../rpmio/.libs/librpmio.a(rpmio.o) dlsym /usr/lib/libnsl.a(netdir.o) dlopen /usr/lib/libnsl.a(netdir.o) dlerror stpcpy ../rpmio/.libs/librpmio.a(rpmio.o) dlsym /usr/lib/libnsl.a(netdir.o) dlopen /usr/lib/libnsl.a(netdir.o) dlerror /usr/lib/libnsl.a(netdir.o) ld: fatal: Symbol referencing errors. No output written to dump make[2]: *** [dump] Error 1 /usr/lib/libnsl.a(netdir.o) 3) If I add '-static' to LDFLAGS I get an error: make LDFLAGS="-static" /bin/sh ../libtool --mode=link gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -static -o dump dump.o ../build/librpmbuild.la ../lib/librpm.la ../rpmio/librpmio.la ../popt/libpopt.la mkdir .libs gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -o dump dump.o ../build/.libs/librpmbuild.a ../lib/.libs/librpm.a -ldb-3.1 ../rpmio/.libs/librpmio.a -L/usr/local/lib -L/usr/ucblib -lnsl -lsocket -lz ../popt/.libs/libpopt.a -R/usr/local/lib -R/usr/ucblib -R/usr/local/lib -R/usr/ucblib Undefined first referenced symbol in file stpcpy ../rpmio/.libs/librpmio.a(rpmio.o) ld: fatal: Symbol referencing errors. No output written to dump
Solution 3) is almost there, but you will need to add link with misc/libmisc.a (which should have a portable version of stpcpy on solaris).
Please add detailed documentation of this to the INSTALL page in the source code.
whoops, the last comment was for a similar bug on the RPM module. What I mean is we need better documentation of this stuff in general RPM needs documentation on how to use libtool in its INSTALL section and libtool info pages needs documentation of 1) using '-static' on solaris, which is known to be a problem 2) linking an executable with a particular .a file which I have installed on my system but was not created with libtool Both of these are standard linking operations and both are hard when using a combination of libtool and solaris.
I can not make your suggestion work 1)First I have a problem in the make make LDFLAGS="-static ../misc/libmisc.a" before most of the ojbects exist: make[4]: Entering directory `/data1/builds/1/BUILD/rpm-4.0/popt' /bin/sh ./libtool --mode=link gcc -Wall -O2 -static ../misc/libmisc.la -o libpopt.la -rpath /usr/local/lib popt.lo findme.lo poptparse.lo poptconfig.lo popthelp.lo -L/usr/ucblib -R /usr/ucblib libtool: link: `../misc/libmisc.la' is not a valid libtool archive make[4]: *** [libpopt.la] Error 1 make[4]: Leaving directory `/data1/builds/1/BUILD/rpm-4.0/popt' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/data1/builds/1/BUILD/rpm-4.0/popt' make[2]: *** [all-recursive-am] Error 2 make[2]: Leaving directory `/data1/builds/1/BUILD/rpm-4.0/popt' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/data1/builds/1/BUILD/rpm-4.0' make: *** [all-recursive-am] Error 2 If I build the whole thing with no LDFLAGS="-static" till I get an error then try to build the error with new LDFLAGS I get a new error res03$ make LDFLAGS="-static ../misc/libmisc.la" make[2]: Entering directory `/data1/builds/1/BUILD/rpm-4.0/tools' /bin/sh ../libtool --mode=link gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -static ../misc/libmisc.la -o dump dump.o ../build/librpmbuild.la ../lib/librpm.la ../rpmio/librpmio.la ../popt/libpopt.la libtool: link: `../misc/libmisc.la' is not a valid libtool archive make[2]: *** [dump] Error 1 make[2]: Leaving directory `/data1/builds/1/BUILD/rpm-4.0/tools' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/data1/builds/1/BUILD/rpm-4.0' make: *** [all-recursive-am] Error 2 OR I can run as you suggested and get this error make LDFLAGS="-static ../misc/libmisc.a" make[2]: Entering directory `/data1/builds/1/BUILD/rpm-4.0/tools' /bin/sh ../libtool --mode=link gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -static ../misc/libmisc.a -o dump dump.o ../build/librpmbuild.la ../lib/librpm.la ../rpmio/librpmio.la ../popt/libpopt.la gcc -O2 -D_GNU_SOURCE -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts ../misc/libmisc.a -o dump dump.o ../build/.libs/librpmbuild.a ../lib/.libs/librpm.a -ldb-3.1 ../rpmio/.libs/librpmio.a -L/usr/local/lib -L/usr/ucblib -lnsl -lsocket -lz ../popt/.libs/libpopt.a -R/usr/local/lib -R/usr/ucblib -R/usr/local/lib -R/usr/ucblib Undefined first referenced symbol in file stpcpy ../rpmio/.libs/librpmio.a(rpmio.o) ld: fatal: Symbol referencing errors. No output written to dump OR I tried this res03$ make LDFLAGS="-static" myLDADD="../build/librpmbuild.la ../lib/librpm.la ../rpmio/librpmio.la ../popt/libpopt.la ../misc/libmisc.la" make[2]: Entering directory `/data1/builds/1/BUILD/rpm-4.0/tools' make[2]: *** No rule to make target `../misc/libmisc.la', needed by `dump'. Sto
Is this fixed with newer versions of rpm/libtool? Thanks, Florian La Roche
Please submit patches that can be added, otherwise solaris is not one of our supported platforms. Florian La Roche