New feature for MFC vNext: small statically linked dialog based and console apps

If you’ve read my blog in the past, you’ve noticed that I’ve written several articles relating to reducing the size of statically linked MFC apps. Ever since the feature pack classes were added to MFC (in 2008 SP1) there have been various regressions that caused even the simplest of MFC applications to be super-large when building a release version.

In vNext, Microsoft has attempted to address this issue by adding a new define: _AFX_NO_MFC_CONTROLS_IN_DIALOGS that basically says: I know that I will not have any of the “feature pack” controls in my app, so don’t link any code into the app that I’m not going to need.

From my testing so far, it only appears to work in console apps and MFC Dialog based apps. If you use it with a single document interface app, it will fail with a linker error.

The sizing results are dramatic, and I suggest you give the define a try if you are using MFC vNext and have a statically linked app.

Advertisements

About tedwvc
On this blog you'll find some tips and tricks for dealing with Visual C++ issues.

One Response to New feature for MFC vNext: small statically linked dialog based and console apps

  1. tedwvc says:

    With the Visual C++ 2012 RC this now works with MDI and SDI apps also (just ensure you don’t choose any of the options that include feature pack classes, and also change references of CDialogEx to CDialog)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: