Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC VS2010
I am working on MFC dialog based application but the size of executable in Release mode when i statically linked the dll is very large. I googled it and found one solution in this link Click here->[^].I tried this solution but it is not reducing the size of dialog based application.
 
Can anyone have solution of this problem??
 
Thanks in advance Smile | :)
Posted 24-Nov-10 19:23pm
ShilpiP11.2K
Edited 24-Nov-10 20:19pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You have two places in the project propertiess where to set-up settings that could affect the executable size:
 
  1. under the Optimization subsection of C/C++ section: there are two settings, the first one is Optimization, its default is Maximize Speed (/O2), and you could change it to Minimize Size (/O1). The second one is Favor Size or Speed, its default is Neither, and you could change it to Favor Small Code (/Os).
  2. under the Optimization subsection of Linker section: there are two settings, the first one is References, and you should ensure to set it to Eliminate Unreferenced Data (/OPT:REF). The second one is Enable COMDAT Folding, and you should ensure to set it to Remove Reduntant COMDATs (/OPT:ICF).
  Permalink  
Comments
Shilpi Boosar at 25-Nov-10 5:16am
   
Hi Sauro Viti,
Thanks for ur reply.
I did the same but the size is reduced from 1.61 mb to 1.60 mb.
Sauro Viti at 25-Nov-10 5:30am
   
I'm sorry, but be aware that MFC is a quite huge and intrusive framework: to get a statically linked executable of 1.60 MB is not a bad result... If you really need a very small footprint you should consider using a different approach. You could try the WTL (Windows Template Library): its based on ATL and share a quantity of classes with MFC (like CString, CList, CMap, etc.).
Porting your application to WTL could require a while, but the result in terms of size will be great.
Shilpi Boosar at 25-Nov-10 5:39am
   
Hi Thanks again,
Yae i know but the size of executable can be reduced up to 600 to 700 kb.The URL that i have given with my question does the same but i am not succeeded :(. something is missing :(
If i dont found any solution than i work on alternate solution obviously :)
Thanks :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think there is a compiler option to optimise for size which may make a small difference. Also ensure you have a release build and are linking to the release mfc libs (the ones without a d at the end of the name).
 
The main reason your exe is so large is all the mfc libs you are usinging are statically included in your exe. If you dynamically link your exe will be much smaller but you will need to distribute the mfc dlls you use.
  Permalink  
Comments
Shilpi Boosar at 25-Nov-10 4:43am
   
Hi ARopo,
Thanks for your reply. but it is not a feasible solution to distribute mfc dll.
Do you know the compiler option mentioned in your answer??
ARopo at 25-Nov-10 12:18pm
   
/01
 
Under project properties c/c++-optimization-Optimization Minimum Size(/o1)
ARopo at 25-Nov-10 12:20pm
   
Also Favor Size or Speed Favor small(/Os)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I had the same problem when I upgraded to VS2010. Are your dialogs derived from CDialogEx? If so...remove all references to CDialogEx and instead derive your dialog from CDialog and your executable size will drop dramatically. There is abnormal MFC executable size caused by the Visual Studio 2010 "Feature Pack" headers which include a bazilliontrillion unneccesary other headers and libs which will be linked into your binary.
 
Best Wishes,
-David Delaune
  Permalink  
Comments
Shilpi Boosar at 25-Nov-10 13:31pm
   
Hi thanks for ur reply .. but this i already did but the size remains same :(( please check the link that i had given with my question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 389
1 Maciej Los 180
2 Richard MacCutchan 140
3 DamithSL 129
4 Kornfeld Eliyahu Peter 119


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 25 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid