R – Creating & using an MFC static library

mfcstatic-librariesvisual studio

Is it possible to create an MFC static library (.lib) and link it to a non-MFC C++ application? If so, does anyone know how to create an MFC static library? Visual Studio doesn't seem to have any templates like that.

Best Answer

Well, it turns out that there is a template for an MFC static library; it's just well hidden—it's in the Win32 templates instead of the MFC templates.

All you have to do is create a standard Win32 project and choose "Static library". At that point the MFC checkbox is enabled and you're good to go.