Why is my C++ binary so large?

erezsh

New member
Why is my C++ binary so large?

מתוך ה-FAQ של MinGW32
C++ programs using the Standard Template Library (ie/ #include <iostream>) cause a large part of the library to be statically linked into the binary. The need to statically link the stdc++ into the binary is two fold. First MSVCRT.dll does not contain C++ stdlib constructs. Second the legal implications of generating a libstdc++.dll are restricted by the licensing associated with the library. If you wish to keep your file size down use strip to remove debugging information and other verbatim found in the binary.​
 

selalerer

New member
זה היה טיפ לפורום.

בכדי שנשכיל, נחכים, נלמד, נגדל, נתהדר, ונתפאר וכו'....
 

eyalbd

New member
תקטין אותו כך:

strip --strip-all program.exe Numbers on linux of "hello world" program Without strip 13494 bytes With strip 4248 bytes​
תוכל גם לשחק עם האופציות הבאות שמשפיעות על גודל התוכנית: -fno-implicit-templates -fno-exceptions -fno-rtti -Os (reduce size) יש עוד הרבה אופציות לGCC קרא על אלו ואחרות בתיעוד.
 
למעלה