fatal error C1189

下面是程序的错误! 
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] 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值