static link

Ben Lindstrom mouring at
Thu Feb 28 12:59:52 EST 2002

On Wed, 27 Feb 2002, Oliver Joa wrote:

> hi,
> i have downloaded the linux-version of openssh-3.0.2p1. i wanted
> to compile it statically with the following configure-statement:
> ./configure --prefix=/usr/local/opt/openssh-3.0.2p1 --with-pam
> --with-md5-passwords --with-v4-default --with-ldflags=-static
> --with-ssl-dir=/usr/local/opt/openssl

first off.. --with-md5-passwords is a worthless option if --with-pam
is set.  Since pam handles des vs md5 vs "password encryption of the
month club".

> It worked for the older 2.9 version, but now i get the following error:
> gcc -o ssh ssh.o sshconnect.o sshconnect1.o sshconnect2.o sshtty.o
> readconf.o clientloop.o -L. -Lopenbsd-compat/
> -L/usr/local/opt/openssl/lib  -static -lssh -lopenbsd-compat -lpam -ldl
> -lutil -lz -lnsl  -lcrypto
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libc.a(getopt.o): In
> function `_getopt_internal':
> /usr/src/build/40453-i386/BUILD/glibc-2.2.4/posix/getopt.c:516:
> multiple definition of `optind'
> openbsd-compat//libopenbsd-compat.a(getopt.o):/home/olli/openssh-3.0.2p1/openbsd-compat/getopt.c:64:
> first defined here

Second off.. Since glibc does not support 'int optreset;' functionality
implemented in most BSDes.  We have to include our own.  As a result
a clash occurs on staticly compiling.

To hack around to support -static on most platforms lacking optreset
is too ugly to implement IMNSHO (and I think others agreed by lack
of implementing it).

If you really wish to play around go to openbsd-compat/getopt.c

and change 'opterr' and 'optind' to

extern int opterr;
extern int optind;

However if your mother dies due to the fact a crosswalk turns green
while the redlight is on.. It is not our fault. =)

And the concept of -static and --with-pam are not always compatible.

- Ben

More information about the openssh-unix-dev mailing list