How to static compile program?
I have written a simply code,but I can't compile it staticly.
My development tools is sun studio 11.
cc -g -xCC -c-o Sun-x86-Solaris/shellcode.o shellcode.c
cc -g -xCC-o Sun-x86-Solaris/a.out Sun-x86-Solaris/shellcode.o -Bstatic
ld: fatal: library -lc: not found
ld: fatal: File processing errors. No output written to Sun-x86-Solaris/a.out
*** Error code 1
Perhaps solaris 10 can't compile staticly.
# 1
Static system libraries are no longer provided, starting with Solaris 10.
The reason is that programs linking a static system library from one release or patch level of Solaris cannot be guaranteed to work on a different release or patch level -- they may depend on system internals that are different.
Since every Solaris system has libraries that work correctly, there is never any need to link the libraries statically.
# 3
Its not only impossible, it is also dangerous (that is, strictly speaking, if you plan to run your code on any other machine _or_ install patches on your machine).There's a good article about that: see http://blogs.sun.com/rie/date/20041206