c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(24) : fatal error C1189:
#error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
TestMain.cpp
c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(24) : fatal error C1189:
#error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
#error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
使用多线程动态连接运行时库的MFC程序, 需要使用MFC动态连接库.
改工程设置:
Project|Properties|Configuration Properties|General|Use of MFC : Use MFC in a
Shared DLL
编译环境 VC++.net2005环境,在编译某dll时出现如下错误提示:
错误 1 fatal error C1189: #error : Building MFC application with /MD
[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or
do not use /MD[d] C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc
\include\afx.h 24
从网上搜索查了一下,修改 项目-属性-配置属性-常规-MFC使用 设置为 “在共享DLL中使用MFC”
或 修改 配置属性-C/C++-代码生成-运行时库 设置为 "多线程DLL(/MD)"
错误均未消除,修改成其他选项会提示错误提示 “Please use the /MD switch for ……”
修改运行库会提示
fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
请问如何才能正确编译?
静态链接mfc库的话,那么运行库也得设置成静态链接。
动态链接mfc库,运行库也得设置成动态链接。
就这两个选项,设置成一致即可。
fatal error C1189: #error : Building MFC application with /MD (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD
这是由于VS2005默认的MFC程序是使用动态MFC库(Use MFC in a Shared DLL)来链接的而动态MFC库使用的是Multi-threaded DLL (/MD),由于XP对于PE文件格式监测更加严格,所以要进行如下的项目设置修改:
[Project Properties] -->[Configuration Properties] --> [c/c++] -->[Code Generation]-->[RunTime Library]这里要改成[Multi-threaded (/MT)]
再编译,通过了,但出现了一个Link错误:
corelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup
现在要做如下修改,因为程序默认Entry Point找不到了,重新打开项目设置
Project Properties] -->[Configuration Properties] --> [Linker]-->[Advanced]-->[Entry Point]-->把[wWinMainCRTStartup]改成[WinMainCRTStartup]
本文介绍了解决在VC++ .net2005环境下编译MFC程序时遇到的致命错误C1189的方法。通过调整项目设置中的MFC使用方式和运行时库设置,确保MFC和CRT的链接方式一致。

被折叠的 条评论
为什么被折叠?



