0

我是 CodeLite 的新手

每次我按 F7 编译项目时,它都会产生一个巨大的 exe

#include <iostream>

int main(int argc, char *argv[]){
        return 0;
}

短代码但 900KB

我已经切换到发布模式,问题仍然存在。

并且我自己在 CMD 中尝试过相同的命令行,g++ 只产生 49 KB

我猜codelite使用的makefile是关键??

4

2 回答 2

0

The size of the executable is not related to the Makefile, but because of the inclusion of iostream (removing it will reduce your exe to the minimum)

However you might want to add '-s' to the linker options from: project settings -> common settings -> linker

adding '-s' will reduce the executable by half to around ~400KB in release mode. You can also try and run 'strip' on the executable

Eran

于 2013-04-23T19:23:32.607 回答
0

将 -ffunction-sections 传递给每个编译,将 --gc-sections 传递给最终链接(或 -Wl,--gc-sections 传递给 gcc)以启用死代码的剥离。

于 2013-04-23T14:24:52.033 回答