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

来源:互联网 发布:淘宝怎么找人代付款 编辑:程序博客网 时间:2024/06/05 00:32

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的定

(4.2) Use MFC in a Shared DLL
:与(4.1)相比,增加了_WINDLL,_AFXDLL的定
编译参数:没有太大区
接参数:/nologo/dll /incremental:yes /pdb:"Debug/Win32DllDemo.pdb"/debug/machine:I386/out:"Debug/Win32DllDemo.dll"/implib:"Debug/Win32DllDemo.lib" /pdbtype:sept
可以看出,(4.1)
接的很多消失了,这时4成了似于2中的置。需要注意,4stdafx.h包含了<windows.h>,此如果要用MFC,需要自己加入MFC的几个文件(<afxwin.h><afxext.h>等),并且将#include <windows.h>DllMain入口函数注掉!
(4.3) Use MFC in a Static DLL
使用MFC DLL的方式SharedStatic
的区与上述似,不再做比
5.Win32 Static Library

预编译头文件stdafx.h(可能没有个文件):
不使用MFC
仅仅#define WIN32_LEAN_AND_MEAN,而如果使用MFC,内容如下:
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afx.h>  #include <afxwin.h>
(5.1) Not Using MFC    
WIN32,_DEBUG,_MBCS,_LIB,新出了符号_LIB
编译参数:/nologo/MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB"/Fp"Debug/W32StaPrehead.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD/GZ    /c
注意到使用的Run-time library参数
/MLd
参数:目没有Link,代替的是Library,参数如下:/nologo /out:"Debug/W32StaPrehead.lib"
(5.2) Use MFC in a Shared DLL
WIN32,_DEBUG,_WINDOWS,_MBCS,_AFXDLL,与1MFC Exe置相同。
编译参数:注意使用的Run-time library参数/MDd
参数:没有太大区
(5.3) Use MFC in a Static DLL
编译参数:注意使用的Run-time library参数/MTd
6.Win32 Application

预编译头文件stdafx.h
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h> // Windows Header Files:

#include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> // C RunTime Header Files
Win32程序的入口函数WinMain
目,Project->settings->General置使用MFC的方式,一般设为Not Using MFC,否程序构的改大。从Not Using MFC到使用MFC的改对连接的的影响似于4Win32 DLL)。
(6.1) Not Using MFC
WIN32,_DEBUG,_WINDOWS,_MBCS
编译参数:/nologo/MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB"/Fp"Debug/W32StaPrehead.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD/GZ    /c
注意到使用的Run-time library参数
/MLd
接参数:kernel32.libuser32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.libole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo/subsystem:windows /incremental:yes /pdb:"Debug/W32AppDemo.pdb" /debug/machine:I386 /out:"Debug/W32AppDemo.exe" /pdbtype:sept
(6.2) Use MFC in a Shared DLL
编译参数:注意使用的Run-time library参数/MDd
(6.3) Use MFC in a Static DLL
编译参数:注意使用的Run-time library参数/MTd


1.MFC
的使用方式
情况选择Run-time library的影响(Debug版本)
Not Using MFC //MLd:Debug Single-Threaded
(静
态连LIBCD.LIB
Use MFC in a Shared DLL //MDd: Debug Multithreaded DLL
动态连MSVCRTD.DLL
Use MFC in a Static DLL //MTd:Debug Multithreaded
(静
态连LIBCMTD.LIB
2.
如果不使用MFC,在Link
一般会接一系列Windows API文件;如果使用MFC就会消失
3.Debug
版本一般会有_DEBUG
,而Release版本NDEBUG
4.
使用Shared MFCStatic MFC相比,前者一般多一个_AFXDLL的定
。默使用的Run-time Library也不一,前者/MDd,后者/MTd
5.MFC
的普通DLL
目比MFCEXE目,一般多_WINDLL_USRDLL接参数多一个/dllMFCDLL目与MFC普通DLL目相比,_USRDLL成了_AFXEXT
6.不使用MFCWin32 DLLMFC DLL相比,少了_WINDLL_AFXDLL,而保留了_USRDLL
7.
不使用MFC的静
态库_LIB
8.#include <afxwin.h>
#include <windows.h>不能重
包含,前者用于MFC程序,后者用于程序。
9.
了去掉Windows文件中很少用到的定,一般在stdafx.h中,Win32程序会定#define WIN32_LEAN_AND_MEAN,而MFC程序会定#define VC_EXTRALEAN
10.本文的用,改变项目参数置,实现不同目之转换,如下:
MFC Exe     <======> MFC DLL  
    ||                    ||
Win32 Exe <======> Win32 DLL


原创粉丝点击