Size of C++ executable

Size of C++ executable

Does one need a runtime DLL for an .exe file written with MFC in Visual C++? Can one make a standalone .exe program with C++ that is small and easily portable?

Obviously, the size of an executable depends on the development tools you use. In the case of VC++, the product does a good job of making the resulting program file(s) as small as possible. Recent versions of VC++ have become very good at optmizing C statements and omiting unused code.

Of course, in a time of increased functionality, those files can still be big. As a result, you may want to distribute the MFC DLLs as separate files. If your users have more than one program on their system that was built this way, then they would only need one copy of those DLLs on their system.

However, I’ve seen my share of problems caused by those shared DLLs when they weren’t always compatible with newer versions. As a result, I always compile everything to a single EXE.

To do this in VC++, go into the Project | Settings menu and select Win32 Release in the Settings for box. Then, from the Microsoft Foundation Classes combo box, select ‘Use MFC in a Static Library.’ If this option is not available, then you probably did not include the required files when you installed the program. Run Setup again and include the static MFC library.

I have some sizable programs compiled this way and they can run about 400K.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist