如果我用 MinGW 编译 C hello world,生成的 exe 大小为 42Kb。如果我使用 Tiny C 编译器,我会得到 2Kb 的东西。 (在这两种情况下,无需指定任何选项或执行任何有趣的操作,只需 gcc hello.c -o hello.exe)
现在我知道需要最少的启动代码;但是 mingw 放在那里的额外 40kb 的东西是什么,它有什么作用,为什么需要它?
最佳答案
来自the FAQ :
Debugging Information
The most common reason why executables are larger than expected is that they include debugging information, which is generated when source files are compiled with the "-g" option to GCC. Even when your own source files are compiled without debugging information, libraries linked with your executable may have been compiled with "-g" (possibly including system libraries that are distributed with MinGW).
To exclude debugging information from your executable, simply use the "strip" command to remove it, or alternatively use the "-s" option when linking.
UPX (Ultimate Packer for eXecutables)
UPX is a tool that can decrease the size of executables, using very fast and very efficient in-place compression/decompression. It works for Windows and Linux executables and is free for use with all applications (including commercial apps).
关于c - MinGW - 为什么 C 'hello world' 可执行文件有 42kb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40693482/