在一些静态库中打开整个程序优化大大增加了库大小! [英] Turning on whole program optimization in some static library increases dramatically the library size !

查看:817
本文介绍了在一些静态库中打开整个程序优化大大增加了库大小!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010中,我有一个C / C ++静态库项目。当我在发布模式中打开整个程序优化选项时,我会获得超过90 MB的.lib文件!
当我关闭这个选项的大小减少到24 MB。
这个库包含用原缓冲区生成的数百个类。

In Visual Studio 2010, I have a C/C++ static library project. When I turn on the option whole program optimization in release mode, I obtain a .lib file exceeding 90 MB ! When I turn off this option the size is reduced to 24 MB. This library contains hundreds of classes generated with proto-buffer.

我想知道为什么这个选项增加了大小?
在哪些情况下我们必须关闭?

I'm wondering why this option increases the size ? Under which conditions we must turn it off ?

编辑:将MO更改为MB感谢chrisaycock

Edit : Changed MO to MB thanks chrisaycock

推荐答案

整个程序优化意味着在链接阶段之前没有优化。

Whole program optimization means things are not optimized until the link stage.

静态库不是要看的东西。当处于这种模式时,静态库可能充满了最终优化/链接阶段所需的额外信息。如果你没有做整个程序优化,那么这些信息可能会在静态库构建后被丢弃,但是当你是信息必须保持到结束。

The size of a static library is not the thing to look at. When in this mode, the static library may be full of extra information needed for the final optimization/link stage. If you weren't doing whole program optimization then that information could have be thrown away after the static library was built, but when you are that information has to be kept until the end.

看看最终的可执行文件的大小。 (它可能仍然增加,但它不应该增加如此巨大的金额。)

Look at the size of the final executable instead. (It may still increase, but it shouldn't increase by such a huge amount.)

这篇关于在一些静态库中打开整个程序优化大大增加了库大小!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆