减少窗口可执行文件大小

减少窗口可执行文件大小

本文介绍了减少窗口可执行文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上有一个C ++ / MFC应用程序 - 动态链接它只有60kb静态的> 3Mb。

它是通过电子邮件分发给客户,因此需要尽可能小。

I have a C++/MFC app on windows - dynamically linked it's only 60kb static it's > 3Mb.
It is a being distributed to customers by email and so needs to be as small as possible.

它静态链接MFC和MSCVRT库 - 因为它是一些问题的修复,我不想更多关于丢失libs的支持调用 - 特别是非常有用的应用程序配置是不正确的一个!

It statically links the MFC and MSCVRT libraries - because it is a fix to some problems and I don't want more support calls about missing libs - especially the very helpful 'application configuration is incorrect' one!

有没有反对剥离所有额外的MFC的东西,这是dll,但我不使用的Windows exe? />
或者让它动态链接MSVCRT(必须存在),但静态链接可能不是的MFC dll。

Is there anyway to strip a Windows exe of all the extra MFC stuff that is the dll but that I'm not using?
Or tell it to dynamically link MSVCRT (which must be present) but statically link the MFC dll which might not be?

编辑 -

推荐答案

你不能混合使用CRT / MFC DLL。从内存...

You can't mix the CRT/MFC dlls. Going from memory...

正如其他答案建议的,你可以#define WIN32_LEAN_AND_MEAN和VC_EXTRALEAN。这些可能不会帮助。他们倾向于最小化构建时间 - 而不是最终的exe大小。

As the other answer suggested, you can #define WIN32_LEAN_AND_MEAN and VC_EXTRALEAN. These probably won't help though. They tend to be about minimizing build time - not the final exe size.

缺少重建MFC(这是一个选项 - 你可以重建它/ Os,感觉真的很酷,/ GL - 但这可能会导致更多的下游乐趣 - 希望它已经建成/ Gy)。

Short of rebuilding MFC (Which is an option - you could rebuild it /Os, or if you are feeling really cheeky, /GL - but this will probably lead to more downstream fun - hopefully it's already built /Gy).

确定。简单的东西试试。使用/ GL / Os / GF / Gy / GA构建您的应用程序。在链接器中,你或多或少想要/ OPT:REF和/ OPT:ICF和/ LTCG。

OK. Simple things to try. Build your app with /GL /Os /GF /Gy /GA. In the linker you more or less want /OPT:REF and /OPT:ICF and /LTCG.

我不得不说 - 从30k到megabytes的发布版本有点多。你也可以传递/ map:到链接器,看看什么占用所有的空间 - 但这是非常非常tedius。

I have to say - a release build from 30k to megabytes is a bit much. You could also pass /map: to the linker and see what's taking all that space - but that's very very tedius.

几乎听起来像MFC不是用/ Gy - 但这是令人惊讶的。

It almost sounds like MFC wasn't built with /Gy - but that would be surprising.

这篇关于减少窗口可执行文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:31