Reputation: 119
I have different C++ compilers on my computer, each compiler has its own libstdc++.so and their size is different.
-rwxr-xr-x. 1 root root 967K Mar 22 2017 libstdc++.so.6.0.13
-rwxr-xr-x. 1 root root 6.5M Aug 1 2017 libstdc++.so.6.0.20
-rwxr-xr-x. 1 root root 11M Aug 1 2017 libstdc++.so.6.0.21
-rwxr-xr-x. 1 root root 12M Jan 30 16:58 libstdc++.so.6.0.24
I want to know why libstdc++.so.6.0.13 is so much smaller than others, and is there any way to reduce others' size. I will be glad if some one can help me.
Upvotes: 10
Views: 1527
Reputation: 85541
The versioning scheme of libstdc++ is misleading, the differences between these versions are actually huge when you consider the corresponding GCC versions:
There's been the C++14 implementation between GCC 4.4 and 4.9, and major work on C++17 and various experimental proposals after that.
From libstdc++'s FAQ:
Usually the size of libraries on disk isn't noticeable...
. . . the object files in question contain template classes and template functions, pre-instantiated, and splitting those up causes severe maintenance headaches.
So in short - not much can be done about the size. If you're really interested, you can see what's inside using readelf -a libname.so
You can always downgrade to an older GCC version which will come with a smaller libstdc++.
Having said that, on Ubuntu the size of libstdc++.so.6.0.24
is 1.54MB, so it didn't actually grow that much. There could be something wrong with your specific distro or maybe you grabbed a debug version. You can try stripping debug symbols with strip libstdc++.so.6.0.24
(the strip
utility is part of binutils
).
Upvotes: 10