Mixing Debug and Release Files in an MFC ProjectLast reviewed: July 31, 1997Article ID: Q117499 |
1.00 1.50 1.51 1.52 | 1.10 2.0 2.10 4.00
WINDOWS | WINDOWS NTkbtool The information in this article applies to: The Visual Workbench included with:
- Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, and 1.52 - Microsoft Visual C++, 32-bit Edition, version 1.0, 2.0, 2.1, and 4.0 The information in this article is included in the documentation starting with Visual C++ 5.0. Look there for future revisions.
SUMMARYWhen building large Microsoft Foundation Class (MFC) applications, the debug information can take up a lot of disk space. In order to reduce the size of the application, there are several methods by which you can remove the debugging information from some of the modules in the project and/or from the MFC libraries themselves. Moreover, starting with Visual C++ 32-bit Edition version 2.0, the Visual Workbench supports per-file build rules which can greatly reduce the amount of debug information that is generated for an application.
MORE INFORMATIONThe following are among the methods available to reduce the amount of debugging information included in a project:
Method 1: Use per-file build optionsIf you are using Visual C++ 32-bit Edition version 2.x or 4.0, this is the easiest method. It enables you to specify the /Zd (line numbers only) option, among others, for specific files. Doing so can greatly reduce the amount of debug information that is per module.To set the /Zd switch: 1. Open the Project Setting dialog box.
Method 2: Build the Debug MFC Libraries with Reduced CodeView InformationTry rebuilding the MFC libraries using the /Zi compiler switch instead of the /Z7 compiler switch. This builds a program database (.PDB) file for the entire library that contains all of the symbolic type information. Each time the compiler generates type information for a new symbol when compiling the source files, it checks the .PDB file to see whether this type is already present. If so, the type is not added.
Method 3: Build the Debug MFC libraries Without CodeView InformationThis is the one of the easiest methods for reducing the size of your debug executable file. The only thing lost by using this method is the ability to step into the MFC code itself. All other debug facilities, such as ASSERTs and TRACEs, remain.The following command builds the medium-memory model debug MFC library without CodeView information for Windows (MAFXCWD.LIB):
NMAKE MODEL=M TARGET=W DEBUG=1 CODEVIEW=0Further information on building a static link library variant can be obtained from the README.TXT file that ships with Visual C++ and can be found in xxxx\MFC\SRC\README.TXT (where xxxx is the directory name for the Visual C++ product - by default, MSVC for Visual C++ versions 2.x and earlier, MSDEV for Visual C++ version 4.0).
Method 4: Use the Full Debug MFC Libraries with Only Selected Debug ModulesThis method allows you to step into the MFC source code as well as providing the other debug facilities. This makes use of both the Debug and Release modes of the Visual Workbench makefile, thus making necessary the changes described below (and also making a "rebuild all" necessary when a full release build is required):For Visual C++ versions 2.x and earlier, follow these steps:
Method 5: Use an External Makefile to Mix Release and Debug InformationThis technique eliminates the need to alter the affects of a release build. It also eliminates the need to manually recompile each module to keep the object files up to date. However, you can no longer change compile and link options from within the Visual Workbench. The makefile has to be maintained manually. The important thing to keep in mind is that if you want to link with the debug MFC libraries you must have "_DEBUG" defined for every module. Conversely, if you want the release MFC libraries, you must have "NDEBUG" defined. For more information on writing external makefiles, see "Managing projects with NMAKE" in the TechNote Viewer, which is located in the Visual C++ program group, or consult the "NMAKE Reference" in the Visual C++ Books Online.
|
KBCategory: kbtool
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |