libstdc++

naga raj gnuuser.raj@gmail.com
Mon Aug 27 09:27:00 GMT 2012


Hi Jonathan/Andrew

  Thank you very much for your responses.
  I think I have to select a subset of the C++ standard libraries and
implement a smaller library.

Thanks,
Nagaraju



On Fri, Aug 24, 2012 at 3:09 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 24 August 2012 08:46, naga raj wrote:
>> Hi,
>>
>>    I have ported Gcc-4.6.2 to an embedded target. My C++ compiler is
>> generating huge code size.
>>
>>   #include <iostream>
>>  using namespace std;
>>  int main()
>>  {
>>    return 0;
>>  }
>>
>>    If we execute the above program then all the function in the
>> iostream library are included in the elf as a result size of elf is
>> increased....
>
> Including <iostream> causes global objects to be constructed, so even
> though you're not explicitly using std::cout or std::cin, those
> streams are initialized and code is run (before main) just because
> <iostream> is included.  If you don't need to use it then don't
> include it.  If you do need to use it then obviously the code size is
> larger if you use I/O features than if you don't use them.
>
> That said, libstdc++ isn't really optimised for embedded systems.
> Some configure-time options such as building libstdc++ without
> exceptions can help reduce code size, if you don't need to use
> exceptions.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43852 would also help
> avoid dependency on the I/O facilities.



More information about the Gcc-help mailing list