Subject: Still looking for libdl on Solaris....

From: Simon Convey <[email-masked]>
Date: Tue, 24 Mar 1998 22:44:29 +0000

Is Solaris a dog or wot .....?
    Give a FreeBSD box anyday........

O.K. wu daemon hackers, here's the crack...I've compiled my heavily
modified wu-ftpd using the standard dynamic linking, fine works a treat.

gcc -g -I.. -I../support -L../support -static -o ftpd ftpd.o ftpcmd.o
glob.o logwtmp.o popen.o vers.o access.o  extensions.o  realpath.o acl.o
private.o authenticate.o conversions.o hostacc.o  sigfix.o conn.o -ldl
-lsupport -lsocket -lgen -lauth -lfwall -lnsl
ld: fatal: library -ldl: not found
ld: fatal: File processing errors. No output written to ftpd
*** Error code 1
make: Fatal error: Command failed for target `ftpd'
# ldconfig
ksh: ldconfig:  not found

---

From: Geir Johannessen <[email-masked]>
Date: Wed, 25 Mar 1998 23:53:51 +0100 (MET)

> make: Fatal error: Command failed for target `ftpd'

What you are trying to do is not possible on Solaris. But it can nearly be
done. From ftp://ftp.fwi.uva.nl/pub/solaris/solaris2.html or
http://www.sun.com/smcc/solaris-migration/tools/docs/FAQ/solaris2.html:

#### Start
6.24) I have problems linking my application statically. 

In Solaris 2.x static linking is not supported for any of the system
libraries. All the functions that use /etc/nsswitch.conf (getXXXbyYYY,
getpwXXX, etc) require the dynamic linker to load the code to load these
functions. It is not possible to write configurable/extensible functions in
such a way that dynamic linking is not required. E.g., you can add your own
nsswitch.conf backend which would not be known to programs statically
linked to only the standard backend code.

Programs that link statically against any of the OS libraries may not run
in the next release and are not ABI compliant.

Programs that link statically don't get some dynamic performance
enhancements found in the shared libraries: using hardware multiply/divide
on systems that support it; using fast mem*() operations on UltraSPARC
etc. And you won't pick up performance enhancements in next releases: e.g.,
Solaris 2.5 comes with a 4x faster fread/fwrite and the "Name Server Cache
Daemon".

If you don't care about ABI compliance, i.e., you won't ship your program
as a product and don't care that you may need to recompile after an OS
upgrade, here are some of your options:

Link statically against all but libdl: 

        cc -Bstatic ....  -Bdynamic -ldl -Bstatic

Link against dl* stubs (gethostbyXXX, getpwXXX etc won't work any longer): 

        char *dlopen() { return 0;}
        int dlclose() { return 0;}
        char *dlsym() { return 0;}
        char *dlerror() { return "dynamic linking not loaded";}

If you don't want any dependencies on /usr, link against the dynamic libs
in /etc/lib: 

        cc -Bstatic ... -Bdynamic -R/etc/lib -Wl,-I/etc/lib/ld.so.1 -ldl
                -Bstatic ....

If you still get undefined symbols, check with ldd for all your libraries
if they have any dynamic dependencies. E.g.,

        % ldd /usr/lib/libsocket.so.1
                libnsl.so.1 =>   /usr/lib/libnsl.so.1
                libdl.so.1 =>    /usr/lib/libdl.so.1
                libc.so.1 =>     /usr/lib/libc.so.1
                libintl.so.1 =>  /usr/lib/libintl.so.1
                libw.so.1 =>     /usr/lib/libw.so.1

tells you that if you want to link libsocket statically, you need to link
with -lnsl -ldl -lc -lintl and -lw as well.
#### End

So what you want to do is this:

cc -Bstatic -g -I.. -I../support -L../support -static -o ftpd ftpd.o
ftpcmd.o glob.o logwtmp.o popen.o vers.o access.o extensions.o realpath.o
acl.o private.o authenticate.o conversions.o hostacc.o sigfix.o conn.o
-lsupport -lsocket -lgen -lauth -lfwall -lnsl -Bdynamic -R/etc/lib
-Wl,-I/etc/lib/ld.so.1 -ldl -Bstatic

--
Geir Johannessen          #  [email-masked]
E B Schieldropsvei 35-25  #  http://www.stud.ntnu.no/~joge/
N-7033 TRONDHEIM, NORWAY  #  Tlf private +47-73888989, job +47-73598048
"If at first you don't succeed, destroy all evidence that you tried."

---

From: Bob Luckin <[email-masked]>
Date: Wed, 25 Mar 98 17:35:33 CST

Simon said :-
> modified wu-ftpd using the standard dynamic linking, fine works a treat.

I think you are out of luck.  If I remember earlier postings to the list
correctly, Sun does not supply a static libdl for Solaris 2.  If you check
the FAQ at
   http://www.wins.uva.nl/pub/solaris/solaris2/Q6.24.html
there's some advice there on building statically under Solaris 2 which may
help.

FYI, I found the above URL by looking at Darci Chapman's guide for wu-ftpd on
Solaris 2 (http://www.wildheart.org/wu-ftpd/)...

Hope this helps...

Cheers, Bob
-- 
     "Emit no data, coder ?  Adapt !  FTP Ada, redo C a tad - on time !"
Bob Luckin      [email-masked]      [http://www.dhc.net/~luckin/palindromes.html]

---

From: Simon Convey <[email-masked]>
Date: Wed, 25 Mar 1998 00:55:33 +0000

Bob Luckin wrote:

> I think you are out of luck. .....

Yeah, I'm coming to the same conclusion myself,  Geir Johannessen in Norway has
also run into this...
I can live with though,  it just means that my chroot environment is not as tidy
as I'd like...Oh well.
As a matter of intrest, the hacked wu-ftp I've built perform two chroots, the
first externally via the tis firewall toolkit ( and authenticates using authsrv)
and then chroot s every user to their home directory....) It just means that
registered accounts can't mess with other accounts. I'll publish the source when
it's out out of beta.....

Thanks for the info though,
( I read Casper Dik's Solaris info on static linking. He now works for sun
microsystems in the Netherlands, which is way handy, becasue he frequently
answers on sun-managers too......)   Hello Casper if you're listening...:-)

Kind regards,
Simon Convey. < [email-masked]>