This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Using std::string leads to large size of executable
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: "Sergiy Yakovin" <ysv_ at hotmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 15 May 2003 18:59:03 -0500
- Subject: Re: Using std::string leads to large size of executable
- References: <Law9-OE40paQmeSgpV60000ce32@hotmail.com>
>1)
>#include <string>
>int main()
>{
> std::string("a");
> return 0;
>}
>
>lead to ~200k .exe file.
On linux:
%COMP.sh "-O2" string_size.cc
%ll a.out
-rwxrwxr-x 1 bkoz bkoz 12K May 15 18:51 a.out*
Note the difference. Try to use shared libraries, if possible on your
platform. Then, try to eliminate unused debug info (in 3.4, not 3.3 or
3.2).
>2)
>#include <vector>
>int main()
>{
> std::vector <char> a;
> return 0;
>}
>
>lead to ~50k .exe file.
%COMP.sh "-O2" vector_size.cc
%ll a.out
-rwxrwxr-x 1 bkoz bkoz 12K May 15 18:53 a.out*
>I want to use std::string but it too exspensive with such size wasting. I
>have tried next compilers for first example and got:
>mingw-3.2: 200k
>mingw-3.2 with STLport: 89k
>bcc-5.5: 64k
>bcc-5.6: 62k
I have yet to run across smaller binaries than g++ 3.x and libstdc++ on
linux. Cygwin/mingw may have other issues, like the inability to deal
with weak: see if __GXX_WEAK__ is being defined on your platform. That
would explain the size issue.
>So IMHO subj depend on GNU GCC implementation of std::string.
I think it depends on many things, including debugging information,
compilation flags, object file format, etc.
-benjamin