Build for Generic Linux Solved?

Mike McCarty Mike.McCarty at sbcglobal.net
Tue Jun 5 13:10:08 UTC 2007


Mike McCarty wrote:
> I have some tools which I use on my machine, and which I wish
> also to use on my GF's machine. She runs Debian. I find that
> I cannot use images built on my machine, as it has later
> versions of the shared libs on it, and at program load time
> I get reports of missing shared objects. Surely there is a way to
> build my programs so that they do not depend on the SOs in
> this manner. I've read the man page for ld and for gcc, yet
> haven't managed to figure this out. I thought that using
> gcc -o hellostatic hello.c -Wl,-static might do the job, but
> this fails with
> 
> /usr/bin/ld: cannot find -lgcc_s
> collect2: ld returned 1 exit status
> 
> Somebody please explain to me how to build an image on my machine
> which will run on another distro.

More experimentation shows that this may have done it...

$ gcc -Wl,-M -o hellostatic hello.c -static 2>&1 | less
$ ls -l hello*
-rwxrwxr-x  1 jmccarty jmccarty   4716 Oct 17  2005 hello
-rw-rw-r--  1 jmccarty jmccarty    109 Jul 11  2005 hello.c
-rwxrwxr-x  1 jmccarty jmccarty 126458 Jul 11  2005 hello.exe
-rwxrwxr-x  1 jmccarty jmccarty 390403 Jun  5 08:07 hellostatic

I tried several other things, but this is the one which made
the executable actually grow. Brief perusal of the map seems
to indicate that the libs got included into the image.

Mike
-- 
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!




More information about the fedora-list mailing list