Visual Studio 2010 generated larger executable file size

I have a C ++ application originally written using Visual Studio 6.0

The application is a standard and raw Win32 API, without MFC (* Edit 2), not .NET, statically linked, multi-threaded executable file.

I migrated all versions of Visual Studio until 2010 (today) and still had no problems:

It compiles and works great with VS2010, but the generated executable file size is four times (4) times bigger!

I tried all the parameters that I know (optimization, delete debugging information , etc.) without any results. Of course I'm new to VS2010, but not Visual Studio.

Has anyone encountered this issue? Again: I DO NOT use any frameworks, this is a raw, statically linked Win32 application, no DLL, no ODBC, no network, no .NET

Hoping to see my executable files again, I thank you for any input.

  • Edit 1: Original size = 626 KB (VS6.0, VS2008) Swollen size = 2,013KB (VS2010)

  • Edit 2: After some research and dumping, I found a hidden link to MFC. I initially said that I did NOT use MFC, but he does.

+8
visual-studio-2010 executable size
source share
5 answers

The increase in size may be caused by changes in the MFC. Here is an explanation, and here is a workaround for the same author who brings the size of the executable file back to the regions where it has been since 2008. The workaround involves editing copies of the MFC source files, although there is a process that not everyone can be happy with, and which needs to be repeated after each update, for example after installing the Visual Studio service pack.

Update:

It seems that the OP does not use MFC, so these can be two different problems. I myself experienced an increase in size, but, unfortunately, I can’t say whether MFC is called or not, because my project is statically linked to MFC.

+2
source share

If you use static binding, I suggest using linker linkers if you are compiling on the command line using the syntax:

cl / Ox [your source file (C ++)] [library required, if any] [required resource files, if any] / link / FILEALIGN: 512 / OPT: REF / OPT: ICF / INCREMENTAL: NO

If you build inside the Visual Studio IDE, you check the linker settings by choosing project properties from the menu. In the configuration, select Release and then click the linker settings found in the left pane, this will show you a list of configurations that match the linker’s default settings.

In the command line, under the linker, specify the / FILEALIGN: 512 option in the Advanced Options field and click the Apply button. In the General option under the linker, turn off incremental binding by selecting None (/ INCREMENTAL: NO). In the linker debugging option, select None to generate debugging information. To optimize the linker, you select "Exclude unnecessary data" (/ OPT: REF) in the links and "Delete redundant COMDAT" (/ OPT: ICF) in the "Enable COMDAT collapse" mode.

To optimize the compiler, make sure that the Release setting is selected, click on the C / C ++ tree in the left panel and select Optimization under it, select full optimization (/ Ox). In the "General" section of the "C / C ++" section, select "Disabled" for "Formatted Information Format".

Remember to click the "Apply" button for each change you make.

I hope that everything that I mentioned here would be useful for you, and all this applies to Visual C ++ 2005 and 2008, but I hope it also applies to Visual C ++ 2010, if not, kindly check the documentation included in your visual C ++ 2010 Installation.

+2
source share

If you still have the target platform of the default platform, Any processor? If so, change it to x86 for 32-bit code. I guess this will make the most of the difference. The rest is probably related to changes in compiler optimization (more aggressive cyclic deployment and much more, where the size was sold for speed, since RAM is cheap). I believe that all granular optimizations are still available from the command line, but many of them were hidden in the user interface options panels.

+1
source share

See Are there any tools for tracking bloat in C ++? - Here some methods of analysis are described that contribute to the execution of the size of the executable file. After doing the analysis on both VC 6 and VS 2010, I hope you find something useful.

There is one specific error that hit me when porting from VC 6 to some version of Visual Studio: the value of some optimization parameters changed, and the values ​​that I used in the VC 6 project were no longer supported, and as a result, the exe created by VS was not optimized in general, causing both executable bloating and slow performance. Check your optimization settings in the properties / C / C ++ / Optimization and make sure that optimization is enabled / Ox, / O2 or / O1.

+1
source share

This is due to the fact that Microsoft added functionality in VS2010 that allows HTML components in dialog boxes, so a lot of things get pulled in and linked even if you don’t use it, and optimization and parameters and removing code without links do not help. There is no “good” way to remove code, but there are some hacked methods. Because of this, we collect our critical items on the VS2008. Please note that our non-GUI code actually compiles less than it costs. Hope MS offers an option for this in a patch / patch, so I can do everything on VS2010, but I can’t hold my breath ...

+1
source share

All Articles