Giant executables.. what am I doing wrong?

Steve Dondley stevedondley@attbi.com
Tue Oct 15 03:53:00 GMT 2002


> I'm currently trying to write a program for a linux system with limited
> memory, and as such I'd like gcc to generate small, statically linked
> executables.

As someone new to C, I'm a little confused by the above.  According to GNU C
tutorial I'm reading, using static libraries INCREASES the amount of memory
used.  A direct quote: "An executable created with a shared library can
therefore be far smaller than one created with a static library."  Of
course, once the shared libraries are loaded into memory, the entire program
will take up just as much memory as a statically compiled executable (I
assume).  My understanding is that the real memory savings come when a
second program is started that uses some of the same libraries as the first
program and now they can share the code.  So instead of the same code
occupying two locations in memory, it only occupies one location.  This
saves memory.

I'm not saying you are wrong for wanting to use a static library, I just
don't understand why and I'm trying to learn.

> with the --static option, then strip it with "--strip-all" I get a
> program worth 332 kB(!).

This confuses me as well.  I can't find any documentation about
the --strip-all option in the GCC manual.  (Maybe because I'm new to
Linux/gcc?  I did 'info gcc' and then did a search for '--strip' and 'strip'
but could not find any reference to this option.)  I also did a google
search but that turned up nothing.  How/where can I find out what this does?

Thanks.




More information about the Gcc-help mailing list