1.在程序头添加#include "stdafx.h" 和#include <afx.h>时会出现以下错误
在Win32Project下使用,出现“error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxv_w32.h“
解决方法:在stdafx.h里面把“#include <windows.h>”注释掉,在此处添加“#include "afx.h"”;在afxv_w32.h里,确认#include <windows.h>在#include <zmouse.h>前面。
2.VS2010 MFC 动态编译以静态编译发布
VS2010 c++编写的程序在别人的机子运行不了,缺少mfc100u.dll xxx100d.dll等的解决方法
解决方法: 1.将这些dll打包,和应用程序一起发布;
2.采用MFC静态编译;
使用VS2010编译的程序在windows xp中运行时 经常会出现找不到 相关的DLL文件,我们可以使用静态编译的方法把这些运 行依赖文件打包到*.exe中来,以减少对环境的依赖。
一般可以配置一下两项:
1.Project ->Property->Configuration Properties->General->Use of MFC 选择 Use MFC in a Static Library
2.Project ->Property->Configuration Properties->C/C++->Code Generation->Runtime Library 选择Multi-threaded(/MT)
3.出现错误“error LNK2005: _DllMain@12 already defined in dllmain.obj uafxcwd.lib(dllmodul.obj)”
解决方法“See if you have _AFXDLL and _USRDLL in the preprocessor definitions. Try removing one of them”。
位置:Project->Propertie->C/C++->Preprocessor->Preprocessor Definitions
原句”WIN32;_DEBUG;_WINDOWS;_USRDLL;DATALOG_EXPORTS;%(PreprocessorDefinitions)“把里面_USRDLL删除掉就可以解决此问题。极有可能是加了#include <afx.h>引起这个问题的。
4.错误“ Please use the /MD switch for _AFXDLL builds”
Project ->Property->Configuration Properties->C/C++->Code Generation->Runtime Library,在Runtime Library下选中Multithreaded DLL或Debug Multithreaded DLL。
原文:http://www.cnblogs.com/ike_li/p/3557093.html