Subject: Static 'ls' in Solaris 2.5.1

From: "Marius Strom" <[email-masked]>
Date: Sat, 15 Nov 1997 04:40:34 -0600

Ladies and Gents...

Does anyone out there know of either a URL or can someone point me in the
right direction for building a statically linked 'ls' for Solaris?  I got
fileutils-3.16 and compiled the ls from that.  When I ftp in, ls is
succesful, but ls -l displays nothing.  Thanks for your help...

Marius Strom - [email-masked]
Network Administrator, Twister Communications
http://www.twistercom.com

---

From: Carlos Canau <[email-masked]>
Date: Sat, 15 Nov 1997 18:53:23 +0000 (WET)

Here, for fileutils-3.16 in Solaris 2.5.1:

$ cat INSTALLED/fileutils-3.16.README

configure
make
cd src
gcc -c dlsym.c
gcc -static -o ls  ls.o ls-ls.o dlsym.o ../intl/libintl.a ../lib/libfu.a -lgen
strip ls
cp ls ~ftp/bin
chmod 0111 ~ftp/bin/ls

$ cat dlsym.c

/* $XConsortium: dlsym.c,v 1.1 93/12/06 16:24:15 kaleb Exp $ */
/*
 * Stub interface to dynamic linker routines
 * that SunOS uses but didn't ship with 4.1.
 *
 * The C library routine wcstombs in SunOS 4.1 tries to dynamically
 * load some routines using the dlsym interface, described in dlsym(3x).
 * Unfortunately SunOS 4.1 does not include the necessary library, libdl.
 *
 * The R5 Xlib uses wcstombs.  If you link dynamcally, your program can
 * run even with the unresolved reference to dlsym.  However, if you
 * link statically, you will encounter this bug.  One workaround
 * is to include these stub routines when you link.
 */

void *dlopen()
{
    return 0;
}

void *dlsym()
{
    return 0;
}

int dlclose()
{
    return -1;
}

------------------------------------------------------------------------

	Hope this helps :)
	</canau

---

From: Emil Isberg <[email-masked]>
Date: Sat, 15 Nov 1997 20:16:03 +0100 (MET)

> * is to include these stub routines when you link.

Hmm .. intressting .. I never knew that R5Xlib used that one .. hmm ..
well .. you're never to old to learn.

But that ls wont show usernames .. only uids .. those functions
(getpwuid() etc) are shared link (Solaris doesn't come with an ar-lib for
those :-( ) ..

So what you must do is to create functions to replace those that open
/etc/passwd and /etc/group and converts from uid to username ..

I was going to append it to this mail (so that it get's in the archive
and such) but since it's roughly 4k I thought it is to large ..
You can get it via
URL:http://www.mds.mdh.se/~cel95eig/static_add_to_ls.txt

Perhaps it is good if it is mirrored on the resource web. :-)
I might have a cleanup forced on me. :-/

It's slighly more complicated, but should be as simple to use.
You do exactly the same as for the dlsym.c 
though some have experienced that you need -lmalloc when you link it all
together. :-( .. But I have not the time to trace down why .. :-(

-- 
/Emil
"The woods are lovely, dark and deep.  But I have promises to keep,
And lines to code before I sleep, And lines to code before I sleep."

---

From: Kent Landfield <[email-masked]>
Date: Sat, 15 Nov 1997 14:59:11 -0600 (CST)

# I was going to append it to this mail (so that it get's in the archive
# and such) but since it's roughly 4k I thought it is to large ..
# You can get it via
# URL:http://www.mds.mdh.se/~cel95eig/static_add_to_ls.txt

It is on the Resource Center at  

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

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