Re: gcc and small command line tasks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



James Nickson <jaynicks@xxxxxxxxxxxxx> asks why a hello-world test
produced a 471K executable program.

I suspect that what Jack was seeing in the simple hello.c test is the
difference between static and dynamic linking.  

For example, on Sun Solaris 8:

	% gcc -o hello hello.c
	% ls -l hello
	-rwxrwxr-x  1 beebe staff 6196 Aug 12 06:38 hello

	% gcc -static -o hello hello.c
	% ls -l hello
	-rwxrwxr-x  1 beebe staff 363296 Aug 12 06:39 hello

While dynamic linking is the default on all modern operating systems,
there are cases (e.g., CD-ROM distribution of software and standalone
boot and rescue disks) where static linking is required to avoid
dependencies on shared libraries that might be in different locations
on some remote system than on the system where the executable was
built, or might be corrupted (consider what happens to your Unix
system if /lib/libc.so.1 develops a bad disk block: virtually nothing
can run).


-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: beebe@xxxxxxxxxxxxx  -
- 155 S 1400 E RM 233                       beebe@xxxxxxx  beebe@xxxxxxxxxxxx -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe  -
-------------------------------------------------------------------------------

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux