473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Release of a static .LIB in the VS 2005

Hi everybody !

Could anybody shed some light into the following paradox :

I am creating a static library under VS 2005 VC++ Win32 using MFC. If
compiled right after creating by a wizard, a release version of the LIB
shows the size of almost 2 MB - without any contents of mine ! The
debug version is less then a tenth of it at that...

Is it a problem of some wrong project settings or is it a bug? Or
maybe, this is OK so, then what sense can it have ?

Regards
Victor

Jan 14 '06 #1
7 2544
could you check that your release version is linked dynamiclly against MFC?
if it is linked against the static MFC libraries, that could account for the
difference.

configuration properties -> general ->use of MFC set to 'MFC in a shared
dll'

kind regards,
Bruno.
"Victor" <bi******@chefmail.de> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi everybody !

Could anybody shed some light into the following paradox :

I am creating a static library under VS 2005 VC++ Win32 using MFC. If
compiled right after creating by a wizard, a release version of the LIB
shows the size of almost 2 MB - without any contents of mine ! The
debug version is less then a tenth of it at that...

Is it a problem of some wrong project settings or is it a bug? Or
maybe, this is OK so, then what sense can it have ?

Regards
Victor

Jan 15 '06 #2
Thank you, Bruno

however, this option has been always selected in both debug and release
versions... exactly the way you say.
So, the reason must be elsewhere.

Victor

Jan 15 '06 #3
"Victor" <bi******@chefmail.de> wrote
Could anybody shed some light into the following paradox :

I am creating a static library under VS 2005 VC++ Win32 using MFC. If
compiled right after creating by a wizard, a release version of the LIB
shows the size of almost 2 MB - without any contents of mine ! The
debug version is less then a tenth of it at that...

Is it a problem of some wrong project settings or is it a bug? Or
maybe, this is OK so, then what sense can it have ?

You probably build with /GL & /LTCG in release. The compiler will
save an intermediate representation instead of generated code in that
case. The switch is under General (not C/C++ !)->WPO.

You can run dumpbin on your object files. If it says anonymous object
you have an LTCG object.

Lib size is a poor indicator for actual code size. You really need to
take a look at final linked image file.

-hg
Jan 15 '06 #4
I have checked the switch General/WPO (if I understood it correctly, it
stays for Whole Programm Optimization). Indeed, there were differencies
between the both Debug and Release versions : Debug had 'No Whole
Programm Optimization', during Release had 'Use Link Time Code
Generation'.

Well, I changed the switch for Release to 'No WPO' either. This has
brought an immediate effect : the size of the .LIB file reduced to a
fifth ! (BTW - I meant always the real size of final linked file). It
is still fast 500 MB, nevertheless!

Is it not a bit exaggerated for an empty project? Are there any other
switches I should check?

Victor

Jan 16 '06 #5
"Victor" <bi******@chefmail.de> wrote
I have checked the switch General/WPO (if I understood it correctly, it
stays for Whole Programm Optimization). Indeed, there were differencies
between the both Debug and Release versions : Debug had 'No Whole
Programm Optimization', during Release had 'Use Link Time Code
Generation'. Yes, I'm sorry WPO = Whole Program Optimization. In this case
the actual code generation is deferred to link time. It therefore enables
the compiler to do optimizations that require information from all
translation units (for instance inlining a function that is implemented
in another .cpp file)

WPO can reduce the code size (for the final EXE or DLL), but
modern desktop compilers are probably more geared for faster
code.
Well, I changed the switch for Release to 'No WPO' either. This has
brought an immediate effect : the size of the .LIB file reduced to a
fifth ! (BTW - I meant always the real size of final linked file). It Just to make sure. The .lib file is _not_ the final linked file. Only
EXE or DLL are. is still fast 500 MB, nevertheless!

I take it you mean KB. Otherwise it would really be a lot.

I'm not sure however, you fully understand what's going on.
The .lib is just a container for all object files (much like a tar
file or a zip file without the compression).

You said, you didn't add any source file yourself. So you'll
probably only have the MFC include files. These contain
inline functions and global data. Inline functions are only
emitted if referenced. So you'll probably only have data
symbols.

When you link your EXE or DLL the linker automatically
includes all object file you give on the command line.
Object files from .libs, however, will only be pulled in
if they contain a definition of a symbol that is referenced
by your code. That is, if you create a "Hello World" project
it doesn't matter if you link with a 100MB .lib or not - so long
as no symbols of the library are referenced.

Things get a bit more complicated with C++ code (which
uses COMDAT sections).

If you want a small image, make sure you build your lib
(or actually all of your code) with /Gy and link with /OPT:REF.

Again, only the size of your EXE or DLL is relevant.

-hg

Jan 16 '06 #6
Thank you Holger,

of course, I meant really 500 KB, not MB !..

Well, the size of my finally linked file (now I mean the target .EXE !
) is quite ordinary and makes me no trouble...

As I moved rather recently from the VC++ 6.0 to the VS 2005, only the
size of the .LIB made me wonder... When I created something like this
in 6.0, the LIB size was normally about 20 KB...

Surely, I can live with this situation as well. Pity about the disc
space only...

Victor

Jan 16 '06 #7
"Victor" <bi******@chefmail.de> wrote
Well, the size of my finally linked file (now I mean the target .EXE !
) is quite ordinary and makes me no trouble...

As I moved rather recently from the VC++ 6.0 to the VS 2005, only the
size of the .LIB made me wonder... When I created something like this
in 6.0, the LIB size was normally about 20 KB...
You probably didn't build with debug info in VC 6 (it was off by
default in the wizard IIRC). You can try to turn off /Zi (BTW: You
can always look these up in MSDN Library in the index and there's
a description where you can find the corresponding setting in the
IDE).

That being said, I strongly believe that the improved debug
experience by far outweighes the disk size ;-)
Surely, I can live with this situation as well. Pity about the disc
space only...

:-)

-hg
Jan 16 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed from the code. I tried to implement this thing by...
1
by: Jürgen Kahrs | last post by:
Hello, The beta alpha release (xgawk-3.1.5-beta.20060401) of the xmlgawk project is now available at SourceForge. http://sourceforge.net/projects/xmlgawk/...
2
by: HCF_15 | last post by:
Hi all, I have a small piece of code to use StackFrame to GetMethod, I found it is inconsistent in Debug version and Release version, is there anything I am doing wrong? Here is code, build in...
6
by: laikon | last post by:
Hi, everyone, below is my program to test static pointer data member; class A { private: static A* p; protected: A() {} public: static A* init()
6
by: bjornms | last post by:
The application i build in C#.net is crashing once a month. I can't reproduce the crash. Is there a way to track down where the program crashes, without putting logging everywhere in the code?...
7
by: =?Utf-8?B?R3JpZ3M=?= | last post by:
Hello, After getting some posts on forums.microsoft.com but no solution I was asked to post over here. Hopefully someone here can help with my problem. I have a Windows Forms application...
5
by: sujeet | last post by:
Dear friends, I'm facing a strange problem... My Application is in Debug mode, and the third party static library i'm using is in release mode. When i compile and try to link my...
3
by: Russ | last post by:
I have a Web Service that was originally created with .NET VC 2003, and subsequently converted to the 2005 version. It works fine when built as a debug version, and run on the workstation it was...
2
by: Dave Johansen | last post by:
I just converted a solution from Visual Studio 2003 to Visual Studio 2005 and the Debug mode seems to be running just fine, but the Release mode crashes on the following code: std::ifstream...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.