Static linking.

Stephen Webb stephen@bregmasoft.com
Wed Jun 7 09:24:00 GMT 2000


On Wed, 07 Jun 2000, oliver wrote:
> Hi,
> 
> 	I'm working on a commercial app. which is being proted to linux from win32.
> Since our existing code makes extensive use of STL, I've been looking at
> using libstdc++-v3 to make this effort easier. For distribution, in order to
> keep our memory footprint small, I would like to static link against
> libstdc++ only, leaving libc et al dynamic. The goal is not to have to
> distribute any extra libs with our app.
> 
> 	After playing with gcc and ld extensively, I haven't managed to get this to
> work (gcc 2.95.3). Does anyone have some advice here?

On the linking command line, just add -lstdc++, usually after all your .o files.  It should pick up libstdc++.a,
which gets built by default.  You may have to specify the directory with a -L directive.

That's all there is to it.


Stephen M. Webb
Principal Consultant, Bregmasoft
stephen at bregmasoft dot com


More information about the Libstdc++ mailing list