Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version 错误解决

Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version 错误解决


今天在VS2010中,用C++读取txt文本时,因为用得是CStdioFile类,所以要包含afx.h头文件,

例如:

#include <iostream>

#include <afx.h>

using namespace std;

void main()

{

cout<<"小孩,糖果\n";

}

但是当我导入该头文件时编译就出现了报错:

1>------ 已启动生成: 项目: test, 配置: Debug Win32 ------

1>正在编译...

1>win321.cpp

1>e:\vs2010\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]

1>生成日志保存在“file://e:\MyObject\test\test\test\Debug\BuildLog.htm”

1>test - 1 个错误,0 个警告

========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========

解决方法:右击项目-->属性-->配置属性-->常规,然后在右边的“项目默认值”中的“MFC的使用”选项中选择“在共享 DLL 中使用 MFC”,在运行,解决了。



猜你喜欢

转载自blog.csdn.net/u011263315/article/details/52248741
今日推荐