Using -static-libstdc++ on linux

Using -static-libstdc++ on linux

I am using the newest version of composer :

icpc -v icpc version 12.1.3 (gcc version 4.6.0 compatibility)

but when I run :

icpc test.cpp -gcc-name=gcc-4.6 -gxx-name=g++-4.6 -static-intel -static-libgcc -static-libstdc++ icpc: command line warning #10006: ignoring unknown option '-static-libstdc++'
but running g++ directly there's no problem at all :

g++ test.cpp -static-libgcc -static-libstdc++

So since the version states "(gcc version 4.6.0 compatibility)", I ask how can I pass this option to the linker ?



9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You could name the static libstdc++ specifically in your link line (if it's present). Compatibility doesn't extend to processing many of the g++ command line options (I haven't seen that one).

It's not as simple as that, avoiding the shared link can be troublesome, especially if it's to be incoorporated into a larger build system. Would definitely be better to support the -static-libstdc++ in future releases.

Besides the trouble of locating the correct static lib, then linking directly with it via -L option has the disadvantage of blowing up the shared library size. Using the -static-libstdc++ option with gcc gives a minimum of overhead, but the direct way with intel seem just to insert the whole library no matter how much you use of it.

Hi Bo,
One suggestion is, you can use -Bstatic -l option which should pull in the entire static library by ld. The -static-libstdc++ option was introduced with g++ 4.5recently soI'll file a feature request to support that option with the developers Of course, I'll update you as soon as that is supported.


Kittur, thanks for the suggestions and filing the feature request. Adding -Bstatic does not do it, ld finds the library and links it in, which can be seen by the increase in size of the library, but it does still have a dependence on I remember reading about it some time ago, it's tricky what goes on, one thing that works is to put a symbolic link in a directory and link with -Lsomedir/.

Interesting, I thought -Bstatic should pull in the library you indicate statically, after that you can specify -Bdynamic explicitly on other libs you may want to pull in dynamically. I'll have to try that out and see what's going on.

Atleast you brought up a good issue for which I've filed a feature request, thanks.


I have confirmed that library gets included in total i.e 3MB extra, if you just use one function from libstdc++. Besides as said -static-libstdc++ in gcc is much more clever and include only a minimum, so it makesgood sense to me to support this option.

This issue has been fixed in the latest 2013 release that you can download from the Intel Registration Center...

Leave a Comment

Please sign in to add a comment. Not a member? Join today