Why GCC produces huge executable comparing to VCC?
I have a project that's not really big. With Visual Studio's C++ compiler the executable is 100+KB. But with mingw GCC it goes up to 500+ KB. Same thing happens on Linux. That's for the release build. For debug build GCC produces 1.4MB while VS's C++开发者_开发问答 compiler only produces 400+KB. What's the reason that causes such a huge discrepancy? Does it have anything to do with static/dynamic linking? What can I do to reduce the executable size produced by GCC?
See this page on how to shrink GCC output size: http://wiki.wxwidgets.org/Reducing_Executable_Size
Did you pass the
-s
flag to GCC?Is Visual Studio linking with the CRT statically or dynamically? How about GCC? It's likely that VC is linking dynamically (
/MD
flag, instead of/MT
) whereas GCC is linking statically (-static-libgcc
flag, and otehrs)... try making them consistent and then seeing if there's a difference.One way to tell is to check if your VC-linked executable depends on
msvcr80.dll
(or a different version), and to see if your GCC-linked executable depends on somemingw
DLL. If they do, then they're dynamically linked; if they truly run standalone, then they're statically linked.
精彩评论