Selective linking with gcc/g++/ld

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 code.

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." - cnn.com
Reply to
Chesney Christ
Loading thread data ...

Hello Chesney,

Chesney Christ schrieb in news: snipped-for-privacy@ntlworld.com:

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
http://www.pin-gmbh.com
Reply to
Kurt Harders

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.