3
votes

My goal is to create an MFC/C++ DLL that does not have any dependencies other than the basic Win32 DLLs. So I chose "Use MFC in a Static Library" setting in the project properties -> General -> Use of MFC:

enter image description here

but when I build this DLL and check the result with the Dependency Walker I get this:

enter image description here

Showing dependencies on the following MFC Dlls:

MFC90U.DLL
MSVCR90.DLL
MSVCP90.DLL

So what am I doing wrong here?

PS. I'm using Visual Studio 2008

1
Is incremental link enabled? Does rebuild all help?Werner Henze
MSVCR90.DLL and MSVCP90.DLL aren't MFC binaries.IInspectable
@IInspectable: Well, to be honest, I've never thought about it. But, those files are included if you build the project to use "MFC as shared DLLs." They are also not included in Windows XP installation (maybe even Vista) by default, thus have to be distributed via MSI (and a "DLL-Hell".)c00000fd
Correct, the runtime support libraries are part of the compiler in VS 2008, not the OS. This has only changed with Windows 10, where the Universal CRT is part of the OS.IInspectable

1 Answers

2
votes

I think I got it. What messed me up was the project setting in C++ -> Code Generation -> Runtime Library. It was changed to Multi-threaded DLL (/MD) and then the following was added to the stdafx.h file:

#define _AFXDLL

So to make it statically link to MFC libraries, I had to change the first setting to Multi-threaded (/MT) and comment out the second one.