Selective linking with gcc/g++/ld

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View

Hi all,

I'm working on a small embedded project running on Linux. A fair chunk
of the application code expected to be run is written in "embedded" C++,
ie using objects and classes, but not using resource hungry C++ stuff
such as templates or exceptions. It's basically just object-oriented C

My problem is that the GNU C++ library is very large. It would be more
convenient to link just the symbols in the C++ library that are actually
used. Is there a way to do this ? I have tried using the --static option
on g++, but on an example "hello world" program that gives me a 0.5MB
executable on my Solaris box. Adding the -s option reduces this to about
0.25MB. It doesn't seem likely that the executable needs to be this big,
it looks like it's just lumping the whole library in. I'd not expect the
printf() or exit() functions to reach more than some tens of KB, and the
startup/cleanup code can't be that huge either.

Has anyone encountered this problem before ?


"Jokes mentioning ducks were considered particularly funny." -

Re: Selective linking with gcc/g++/ld
Hello Chesney,

Quoted text here. Click to load it

The whole library is bigger than 250k.

printf is big, because of the floating point print. What do you
need printf for? try to eleminate printf and use your own
formatting routine (not sprintf :-)) and write.

Gruss, Kurt

PiN - Präsenz im Netz GITmbH
Kurt Harders
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline