Subject: How to build static-linked ls on Solaris 2.5.1

From: Wensong Zhang <[email-masked]>
Date: Fri, 30 May 1997 22:29:08 +0800 (HKT)

Hi Wu-ftpd gurus,

I'm trying to use GNU fileutil package to make a static-linked ls on
Solaris 2.5.1, but got

e5000% make ls CFLAGS="-O2 -static" LDFLAGS=-static
gcc -static -o ls  ls.o ls-ls.o ../intl/libintl.a ../lib/libfu.a -lgen
Undefined                       first referenced
 symbol                             in file
dlclose                             /usr/lib/libc.a(nss_deffinder.o)
dlsym                               /usr/lib/libc.a(nss_deffinder.o)
dlopen                              /usr/lib/libc.a(nss_deffinder.o)
ld: fatal: Symbol referencing errors. No output written to ls
*** Error code 1
make: Fatal error: Command failed for target `ls'
e5000% 

By the way, it is OK to make others static-linked file utilities, such as
cp, mv, rm and so on. The version of gcc is 2.7.2.1.

So, what's the problem? any ideas?

Thanks a lot in advance,
Wensong

---

From: Craig Yap <[email-masked]>
Date: Fri, 30 May 1997 11:25:11 -0400 (EDT)

> dlopen                              /usr/lib/libc.a(nss_deffinder.o)

need -ldl

craig

-- 
Craig Yap                                        Email: [email-masked] 
Systems Programmer Guy                           Phone:    (561) 367-3249
Dept of CS&E at Florida Atlantic University      Fax:      (561) 367-2800
http://www.cse.fau.edu/~craig        PGP key can be found on my home page

---

From: Kent Landfield <[email-masked]>
Date: Fri, 30 May 1997 11:57:45 -0500 (CDT)

# 
# > e5000% make ls CFLAGS="-O2 -static" LDFLAGS=-static
# > gcc -static -o ls  ls.o ls-ls.o ../intl/libintl.a ../lib/libfu.a -lgen
# > Undefined                       first referenced
# >  symbol                             in file
# > dlclose                             /usr/lib/libc.a(nss_deffinder.o)
# > dlsym                               /usr/lib/libc.a(nss_deffinder.o)
# > dlopen                              /usr/lib/libc.a(nss_deffinder.o)
# 
# need -ldl
# 

What you need are replacement routines.  If you bind with -ldl you won't create
a static version.

A complete description with associated dl*() utilities was posted to the 
list by [email-masked] (Pedro Melo).  You can get the article from the
Resource Center at

    http://www.landfield.com/wu-ftpd/support/static-ls.how-to

-- 
Kent Landfield                        Phone: 1-817-545-2502             
The Landfield Group                   FAX:   1-817-545-7650             
Email: [email-masked]             http://www.landfield.com/
Please send comp.sources.misc related mail to [email-masked].
Search the Usenet Hypertext FAQ Archive at http://www.faqs.org/faqs/

---

From: Jim Davis <[email-masked]>
Date: Fri, 30 May 1997 11:32:21 -0700 (MST)

Another question is 'why' -- you should think carefully about the
tradeoffs between dynamic and static linking under Solaris.  The
comp.unix.solaris FAQ has a good discussion of that. 

Contrary to what has sometimes been asserted, it is not necessary to build
a statically linked ls for wu-ftpd to work under Solaris.  And in the most
common case I've heard where it might be desireable (having many guest
accounts or otherwise potentially needing many copies of the shared C
library in the ftp tree) there are some simple alternative solutions.

---

From: Kent Landfield <[email-masked]>
Date: Fri, 30 May 1997 16:33:30 -0500 (CDT)

# Another question is 'why' -- you should think carefully about the
# tradeoffs between dynamic and static linking under Solaris.  The
# comp.unix.solaris FAQ has a good discussion of that. 

Interesting discussion there.  I had not read the FAQ in a long time.
Thanks for pointing the discussion out. Seriously valid points...

I static link utilities that do not require name services.  One reason I 
build static versions is to cut down on the clutter of libraries needed.  
Compare what is listed in the Sun in.ftpd man page with what is listed 
below.  This is my configuration here.  Notice the libraries missing ? 
And wu-ftpd works, ls, ftpconversions and all. ;-) (One of these days 
I'll figure out how to reduce the timezone stuff ... I just haven't 
taken the time to do so.)

/ftp/bin:
---x--x--x   1 root     root      121304 May 30 14:35 compress
---x--x--x   1 root     root      382348 May 30 14:35 gtar
---x--x--x   1 root     root      176544 May 30 14:35 gzip
---x--x--x   1 root     root      200396 May 30 14:35 ls

/ftp/dev:
crw-rw-rw-   1 root     root      13,  2 May 28 13:41 null
crw-rw-rw-   1 root     root      11, 42 Jul  6  1996 tcp
crw-rw-rw-   1 root     root      11, 41 May 28 10:42 udp
crw-rw-rw-   1 root     root      13, 12 Jul  6  1996 zero

/ftp/etc:
-rw-r--r--   1 root     root          73 Jul 30  1996 group
drwxrwxr-x   2 root     root         512 May  7 11:50 msgs
-rw-r--r--   1 root     root         274 Jul 30  1996 passwd

/ftp/etc/msgs:
-rw-rw-r--   1 root     root         738 Apr 23 21:03 banner.msg
-rw-rw-r--   1 root     root         230 May  7 11:47 pathmsg.msg
-rw-rw-r--   1 root     root          70 Jul  6  1996 toomany.msg
-rw-rw-r--   1 root     root          36 Apr 23 21:03 welcome.msg

/ftp/usr:
lrwxrwxrwx   1 root     root           6 May 28 14:16 bin -> ../bin

/ftp/usr/share/lib/zoneinfo:
-rw-r--r--   2 root     root         817 Mar 26 08:52 CST6CDT
drwxrwsr-x   2 root     root         512 Mar 26 08:53 US
-rw-r--r--   1 root     root         817 Jul  6  1996 localtime

/ftp/usr/share/lib/zoneinfo/US:
-rw-r--r--   2 root     root         817 Mar 26 08:52 Central

# Contrary to what has sometimes been asserted, it is not necessary to build
# a statically linked ls for wu-ftpd to work under Solaris.  And in the most
# common case I've heard where it might be desireable (having many guest
# accounts or otherwise potentially needing many copies of the shared C
# library in the ftp tree) there are some simple alternative solutions.

I agree, it is not necessary and wu-ftpd works just fine with dynamic 
libraries.  

In my config there are NO libraries needed in the ftp directory tree. ;-)  
Why this config ? I have a bad case of paranoia.  I like to know all about 
the content of the services I'm running.  Minimal is good.  I have no Solaris 
source license so it only makes sense to me to minimize what is required to 
setup a public ftp facility.  With this configuration I have taken all guess 
work out of the config and can review ALL the source to the visible, publicly
executable tools. Just one man's tastes... ;-)