简体   繁体   English

在发布模式下,库大小更大,而在VS2010中,调试模式下更大

[英]size of library is bigger in release mode then debug mode in VS2010

Currently i am compiling DLMS library( http://www.gurux.fi/index.php?q=DLMSCOSEMFAQ ) using Visual Studio 2010 (Using C++). 目前,我正在使用Visual Studio 2010(使用C ++)编译DLMS库( http://www.gurux.fi/index.php?q=DLMSCOSEMFAQ )。

I am successfully compiled the library in debug and release mode. 我已在调试和发布模式下成功编译了库。 But When i check the size of both library then release one library( .lib ) have more then double size( 76 MB ) then debug one( 31 MB ). 但是,当我检查两个库的大小,然后发布一个库( .lib )时,其大小再加倍( 76 MB ),然后调试一个库( 31 MB )。

I think release one have smaller size the debug one, is it right? 我认为发布版本之一的调试版本较小,对吗?

Is any setting needed in VS2010? VS2010是否需要任何设置?

Find build release log here http://pastie.org/9687316 在此处找到构建版本日志http://pastie.org/9687316

For debug log here http://pastie.org/9687340 有关调试日志,请参见http://pastie.org/9687340

Changes the Setting - Configuration Properties > General > Whole Program Optimization from "Use Link Time Code Generation" to "No Whole Program Optimization" 将设置- 配置属性>常规>整个程序优化从“使用链接时间代码生成”更改为“没有整个程序优化”

After this change the library size came down from 76MB to 21MB on my machine. 更改之后,我的计算机上的库大小从76MB减少21MB

Check out the attached image. 检查附件图像。 Hope this helps you out. 希望这可以帮助你。

整个程序优化项目设置

You should compare your build settings, esp. 您应该比较构建设置,尤其是。 optimization and library linking (static / dynamic). 优化和库链接(静态/动态)。 If you are unsure, copy your command line for both linker and compiler and we can check it for you here. 如果不确定,请为链接程序和编译器复制命令行,我们可以在此处为您检查。

The command line can be found in the build log, or in project Properties / C/C++ / Command Line and Properties / Linker / Command Line . 命令行可以在构建日志中找到,也可以在项目Properties / C/C++ / Command LineProperties / Linker / Command Line

For compiler the most important settings to look for are /O , /M . 对于编译器,要查找的最重要的设置是/O/M

For linker I would look esp. 对于链接器,我会看起来特别是。 for /OPT . 对于/OPT

Your compiler switches are: 您的编译器开关为:

/c /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\\\" /Fd"Release\\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt GuruxDLMS\\GXDateTime.cpp

What is causing your library to be big is /GL . 导致您的库很大的是/GL For explanation see Release mode static library much larger than debug mode version . 有关说明,请参见发布模式静态库,该库比调试模式版本大得多

I remember checking this after a co-worker complain. 我记得在同事抱怨之后检查了一下。 Try to play with the compiler switches until the size are identical, then check the documentation of those switches 尝试使用编译器开关,直到大小相同,然后查看这些开关的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM