1

Currently i am compiling DLMS library(http://www.gurux.fi/index.php?q=DLMSCOSEMFAQ) using Visual Studio 2010 (Using C++).

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).

I think release one have smaller size the debug one, is it right?

Is any setting needed in VS2010?

Find build release log here http://pastie.org/9687316

For debug log here http://pastie.org/9687340

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Jayesh Bhoi
  • 24,694
  • 15
  • 58
  • 73
  • You can optimize for speed or for size. For example, more functions may be inlined in more places to gain speed, but the tradeoff is larger size. – Luchian Grigore Oct 31 '14 at 09:01
  • Visual studio can perform optimizations which should increase run time speed while sacrificing executable size. Check Configuration Properties->C/C++->Optimization->Optimization. – ChrisWard1000 Oct 31 '14 at 09:02
  • @ChrisWard1000 is optimization is issue then this will not consider for debug mode? Because same code with same settings in both mode. – Jayesh Bhoi Oct 31 '14 at 09:05
  • Optimization in Debug mode is typically not desired because it will make it difficult to debug the code because the compiler will shuffle around instructions to increase speed. – ChrisWard1000 Oct 31 '14 at 09:10
  • possible duplicate of [Release mode static library much larger than debug mode version](http://stackoverflow.com/questions/3101487/release-mode-static-library-much-larger-than-debug-mode-version) – Suma Oct 31 '14 at 09:43
  • @Suma Check now. Edited post. – Jayesh Bhoi Oct 31 '14 at 09:47
  • @dasblinkenlight because some people wanted to close it(see close votes). See i undo the delete question. – Jayesh Bhoi Jan 16 '15 at 10:50

3 Answers3

5

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.

Check out the attached image. Hope this helps you out.

Whole Program Optimization Project Setting

Vishal Gupta
  • 154
  • 9
4

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.

For compiler the most important settings to look for are /O, /M.

For linker I would look esp. for /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. For explanation see Release mode static library much larger than debug mode version.

Community
  • 1
  • 1
Suma
  • 33,181
  • 16
  • 123
  • 191
0

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

Eric
  • 19,525
  • 19
  • 84
  • 147
  • Hi thanks for reply, i am new to VS. what you mean by compiler switches until the size are identical? – Jayesh Bhoi Oct 31 '14 at 09:11
  • The different linking and compiling options in the project properties. You can get the command executed for each build setting and see how they differ – Eric Oct 31 '14 at 09:13