The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions. These functions require the MFC libraries to be linked before the CRT library is linked. http://support.microsoft.com/kb/148652
Solution based on VS2005 (Replace Nafxcwd.lib with Uafxcwd.lib for ~VS2013)
go to project>properties>configuration properties>linker>input
add to "Additional dependency" -> Nafxcwd.lib Libcmtd.lib
add to "ignore specific library" -> Nafxcwd.lib;Libcmtd.lib
order of libraries is important( Nafxcwd.lib;Libcmtd.lib).
One thing to try is to make sure you have:
#include "stdafx.h"
as the first line in your .cpp files. I'm sure that's not the answer in all cases, but it made the identical error go away in my case.
I meet this problem in a MFC solution of Visual Studio 2010, while changing Use MFC in a Shared DLL
into Use MFC in a Static Library
in Project -> Properties -> Configuration Properties -> General.
I solve the problem by the following ways, please locate Project -> Properties -> Configuration Properties -> Linker -> Input at first.
In Debug mode:
uafxcwd.lib;Libcmtd.lib
in Additional Dependencies.uafxcwd.lib;Libcmtd.lib
in Ignore Specific Default Libraries.In Release mode:
uafxcw.lib;Libcmt.lib
in Additional Dependencies.uafxcw.lib;Libcmt.lib
in Ignore Specific Default Libraries.Notice:
;
between the two .lib
files.-d
must be added in the files in Debug mode.be sure that you have #include <afx.h>
in "stdafx.h"
BEFORE other includes like #include <string>
in config linker input
Make sure the C++ runtime library that you are linking with is the same on your static library as well as your executable. Check your project properties C/C++->Code generation->runtime library settings.
Typo. One stupid way you got that is instead of include the header, you inlucde the cpp. e.g.
#include <myclass.cpp> //should be #include <myClass.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With