Microsoft Visual C++ 6.0 各类工程配置说明(一)

来源:互联网 发布:mac重新安装系统教程 编辑:程序博客网 时间:2024/06/09 21:17

1.   基于对话框(/文档/多文档)的MFC程序

#include <afxdtctl.h>     // MFC support for Internet Explorer 4 Common

#include <afxwin.h>      // MFC core and standard components

#include <afxext.h>      // MFC extensions

#include <afxdisp.h>     // MFC Automation classes

#define VC_EXTRALEAN     // Exclude rarely-used stuff from Windows headers

stdafx.h预编译头文件

afxext.h声明MFC一些CBitmapButtonCControlBarCSplitterWnd等)

afxdisp.h中声明了Ole的几个COleExceptionCOleVariant等)

afxwin.h声明MFC封装的一些很基本的CWndCViewCButtonCDC等)afxdtctl.h声明几个控件CImageListCMonthCalCtrlCDateTimeCtrl等)Controls

afxcmn.h声明MFC一些控件(CListCtrlCProgressCtrlCToolTipCtrl等)

#include <afxcmn.h>     // MFC support for Windows Common Controls

#ifndef _AFX_NO_AFXCMN_SUPPORT
#endif // _AFX_NO_AFXCMN_SUPPORT

(1.1)Use MFC in a Shared DLL
Debug
版本:
WIN32,_DEBUG,_WINDOWS,_AFXDLL,_MBCS
编译参数:/nologo/MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D"_AFXDLL" /D "_MBCS" /FR"Debug/" /Fp"Debug/ExeDlg.pch" /Yu"stdafx.h"/Fo"Debug/" /Fd"Debug/" /FD /GZ      /c
接参数:/nologo /subsystem:windows /incremental:yes /pdb:"Debug/ExeDlg.pdb" /debug /machine:I386 /out:"Debug/ExeDlg.exe" /pdbtype:sept
Release
版本:
:与Debug版本相比,将_DEBUG成了NDEBUG
编译参数:/nologo/MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D"_MBCS" /Fp"Release/ExeDlg.pch" /Yu"stdafx.h" /Fo"Release/"/Fd"Release/" /FD /c
接参数:/nologo /subsystem:windows /incremental:no /pdb:"Release/ExeDlg.pdb" /machine:I386 /out:"Release/ExeDlg.exe"
(1.2)Use MFC in a Static Library
Debug
版本:
:与(1.1)相比,少了_AFXDLL
编译参数:将/MDd(使用Run-time library: Debug Multithreaded DLL成了/MTd(使用Run-time library: Debug Multithreaded
接参数:与(1.1)相同
Release
版本:
编译参数/MD(使用Run-time library: Multithreaded DLL成了MT(使用Run-time library: Multithreaded
***
注:以上编译/接参数含如下(更多的,参考Msdn):
/nologo
:抑制信息在
编译或者Output Window出;      /MD:运行时库使用MSVCRT.DLL      /W3编译时显Warning级别为3      /GmEnable Minimal Rebuild,一减少重编译选项     /GXEnable Exception Handling        /ZIDebug信息保存的数据文件.PDB中;       /OdDisable码优化;        /FR:生成.SBR文件,包含有符号信息;          /Fp:命名生成的预编译头文件;        /Yu:指定预编译头文件。
2.MFC DLL

预编译头文件stdafx.h
#define VC_EXTRALEAN       // Exclude rarely-used stuff from Windows headers
#include <afxwin.h>            // MFC core and standard components
#include <afxext.h>            // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h>            // MFC OLE classes
#include <afxodlgs.h>          // MFC OLE dialog classes
#include <afxdisp.h>           // MFC Automation classes
#endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h>               // MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h>             // MFC DAO database classes
#endif // _AFX_NO_DAO_SUPPORT
#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>           // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
增加了两个OLE
文件和两个数据文件
(2.1) Use MFC in a Shared DLL
Debug
版本:
WIN32,_DEBUG,_WINDOWS,_WINDLL,_AFXDLL,_MBCS,_USRDLL,与MFC Exe程序相比,增加了_WINDLL_USRDLL
编译参数:与MFC Exe没有太大区
接参数:/nologo/subsystem:windows /dll /incremental:yes /pdb:"Debug/MFCDll.pdb" /debug/machine:I386 /def:"./MFCDll.def" /out:"Debug/MFCDll.dll"/implib:"Debug/MFCDll.lib" /pdbtype:sept
MFC Exe相比,增加了/dll
,以及/def:"./MFCDll.def"/implib:"Debug/MFCDll.lib"注意:其中MFCDll测试目名字,非DLL名字。从目的文件上看,目比MFC Exe生一个.def的文件用于定义导出函数。Release版本与Debug版本的区别类1中的比(上了_AFXDLL)。
(2.2) Use MFC in a Static DLL
(2.1)的区
,主要在使用的Run-time library型上,与1中的比
3.MFC Extension DLL

预编译头文件stdafx.h内容与2相同。
(3.1) Use MFC in a Shared DLL
Debug
版本:
WIN32,_DEBUG,_WINDOWS,_MBCS,_AFXEXT,_WINDLL,_AFXDLL,与2相比,将_USRDLL成了_AFXEXT
编译参数:与上述目没有太大区
接参数:与MFC DLL目相似
Release
版本与Debug版本的区别类1中的比(上了_AFXDLL)。
(3.2) Use MFC in a Static DLL
似以上目的比
(
注:以下
目均以Debug版本述。)
4.Win32 DLL

预编译头文件stdafx.h:
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers                  #include <windows.h>
现项目入口函数DllMain实现
(4.1) Not Using MFC
WIN32,_DEBUG,_WINDOWS,_MBCS,_USRDLL,WIN32DLLDEMO_EXPORTS,与2(MFC DLL)相比,少了_WINDLL,_AFXDLL,而保留了_USRDLL。另外,WIN32DLLDEMO_EXPORTS自定出宏。
编译参数:没有太大区
接参数:kernel32.libuser32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.libole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll/incremental:yes /pdb:"Debug/Win32DllDemo.pdb" /debug /machine:I386/out:"Debug/Win32DllDemo.dll" /implib:"Debug/Win32DllDemo.lib"/pdbtype:sept
MFC DLL
目相比,多了很多接,少了/subsystem:windows的定