Microsoft KB Archive/98656

= INFO: Creating a Browser Library for the Foundation Classes =

Article ID: 98656

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.52 Professional Edition</li></ul>

 Microsoft Visual C++ 1.0 Professional Edition</li></ul>

 Microsoft Visual C++ 4.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q98656

<div class="notice_section">

<div class="summary_section">

SUMMARY
The Microsoft Visual C++ products include the source code for the Microsoft Foundation Class (MFC) Library. Because it is important to understand the implementation of the Foundation Classes when overriding or using member functions, developers are encouraged to construct a Browser database for the Microsoft Foundation Classes source code. Once a Browser database (.BSC file) is created, it can be loaded into the Visual Workbench by choosing File.Open.

This article discusses the following:


 * Modifying the MFC source makefile to create a Browser database without re-building the Foundation Classes Library.
 * Modifying the MFC source makefile to create a Browser database while re-building the library.
 * Integrating the Foundation Classes Browser information into your project.

For more information about the Browser tool, see chapter 7 in the Visual Workbench User's Guide.

NOTE: The distribution CD for Microsoft Visual C++ 32-bit Edition, versions 2.x and 4.0, contains a pre-built browser database for the 32-bit edition of MFC, versions 3.x and 4.0, respectively. This browser database can be found in the MFC source code directory as \MSVC20\MFC\SRC\MFC.BSC for Visual C++ 2.x and as \MSDEV\MFC\SRC\MFC.BSC for Visual C++ 4.0. Although Visual C++ 1.5x is included on the Visual C++ 2.x CD, this CD does not contain a pre-built browser database for the 16-bit version of MFC. Nevertheless, one can be built following the instructions below.

<div class="moreinformation_section">

Modifying the 'makefile' File to Add Rules for Building the .bsc File
Make the following additions to the file called MAKEFILE in the \MSVC\MFC\SRC directory:

<ol>  You'll see the lines: ###############################################################     # Set CPPFLAGS for use with .cpp.obj and .c.obj rules # Define rule for use with OBJ directory # C++ uses a PCH file On the next line after this, include the text: # define compiler options for building just the .BSC file # BSC=1 means browser database only # BSC=2 means browser database with library rebuild !if &quot;$(BSC)&quot;==&quot;1&quot; OPT=$(OPT) /FR$D\ /Zn /Zs !else if &quot;$(BSC)&quot;==&quot;2&quot; OPT=$(OPT) /FR$D\ /Zn !endif </li>  You also see the lines:

###############################################################     # Goals to build

goal: create.dir ..\lib\$(GOAL).lib Change this to: ##############################################################     # Goals to build

!if &quot;$(BSC)&quot;!=&quot;1&quot; goal: create.dir ..\lib\$(GOAL).lib bsc !endif

!if &quot;$(BSC)&quot;==&quot;1&quot; || &quot;$(BSC)&quot;==&quot;2&quot; #Build .BSC file bsc: create.dir $(OBJS) cd $D bscmake /Iu /o $(GOAL).bsc *.sbr del *.sbr

!else bsc:

!endif </li></ol>

These changes will allow you to use the MAKEFILE NMAKE file to create a Browser database for the Microsoft Foundation Classes. You will run the makefile the same as that which is described in the README.TXT file located in the \MSVC\MFC\SRC directory. The only difference is that you can specify whether you want a .BSC file created for the project. Be sure that you understand the information in the README.TXT file before reading further.

See NMAKE.WRI in the \MSVC\MFC\HELP directory for more information about using NMAKE and creating NMAKE files.

Creating a Browser Database without Re-building OBJs or the Library
After you have made the modifications to the MAKEFILE file described above, perform the following steps to create the Browser file (.BSC file) for the Foundation Class Library:

<ol> If you have previously built the library and OBJs already exist in the destination directory (i.e. $MWD), delete the .PCH and OBJs in that directory. You can do this by following the directions in section 3 for the \MSVC\MFC\SRC\README.TXT file.</li>  Make sure you have you have the system environment variables configured correctly (by running MSVCVARS.BAT or VCVARS32.BAT) and invoke the NMAKE command line specifying &quot;BSC=1&quot;. &quot;BSC=1&quot; means that just the browser database (.BSC) will be built. The OBJs and Library will not be built. Here is an example of a command line you might specify: NMAKE MODEL=M TARGET=W DEBUG=1 DLL=0 BSC=1 This will build a file called MAFXCWD.BSC in the $MWD subdirectory under the \MSVC\MFC\SRC directory. See the \MSVC\MFC\SRC\README.TXT file for more information about the NMAKE parameters shown above. </li></ol>

To use the Browser file, start VC++ and select &quot;Open&quot; from the file menu. Choose the .BSC file which you created. The Browser window will appear and you can then look up any of the MFC functions or data variables.

You may want to delete the .PCH file that is located in the same directory as the .BSC file you created.

Creating a Browser Database when Re-building the Library
To create a .BSC file for the Foundation Classes when rebuilding the MFC library, first you must make the modifications shown above to the MAKEFILE file. Next, perform the following steps:

<ol> If you have previously built the library and OBJS already exist in the destination directory (i.e. $MWD), delete the .PCH and OBJs in that directory. You can do this by following the directions in section 3 for the \MSVC\MFC\SRC\README.TXT file.</li>  Make sure you have you have the system environment variables configured correctly (by running MSVCVARS.BAT or VCVARS32.BAT) and invoke the NMAKE command line specifying &quot;BSC=2&quot;. The OBJs and Library will not be built. Here is an example of a command line you might specify: NMAKE MODEL=M TARGET=W DEBUG=1 DLL=0 CODEVIEW=1 BSC=2 This NMAKE command line will build the medium model, Windows, debug, MFC library and place it in the $MWD subdirectory. It will also build a Browser database for the library. The file will be called MAFXCWD.BSC.

See the \MSVC\MFC\SRC\README.TXT file for more information about the NMAKE parameters shown above. </li></ol>

To use the Browser file, start Visual C++ and select &quot;Open&quot; from the file menu. Choose the .BSC file which you created. The Browser window will appear and you can then look up any of the MFC functions or data variables.

Integrating the Class Library Browser Information into Your Project
The text below presents the three steps required to integrate the MFC Library browser information (.SBR files) into your project browser database.

<ol> Create browser information files (.SBR) for the appropriate MFC library.

To create the SBR files, follow the directions above except don't add the makefile line &quot;del *.sbr&quot;. Also, place a &quot;/n&quot; on the BSCMAKE command line. This will prevent the .SBR files from getting truncated to zero when the .BSC file is created. After building the browser database for the MFC library, you will be left with .SBR files as well.</li> Load your project in Visual C++ and modify the compiler options as follows to place the .SBR files for your project into the current directory.

<ol style="list-style-type: lower-alpha;"> Choose Project from the Options menu.</li> Choose Compiler in the Customize Build Options group.</li> Choose Listing Files in the Category group.</li> Clear the Browser Information check box.</li> <li>Choose Custom Options in the Category group.</li> <li>At the beginning of the Other Options field enter &quot;/Fr.\&quot; .</li> <li>Choose OK.</li></ol>

(You must disable browser information for your project to prevent Visual C++ from calling BSCMAKE. If Visual C++ calls BSCMAKE, the browser database includes only .SBR files for files in the project; the MFC Library files are not included.)</li> <li>In Visual Workbench, add an option on the Tools menu to call BSCMAKE, as follows:

<ol style="list-style-type: lower-alpha;"> <li>Choose Tools from the Options menu.</li> <li>Choose Add.</li> <li>In the Add Tool dialog box, specify the path to BSCMAKE in the File Name field (by default C:\MSVC\BIN\BSCMAKE under Windows and C:\MSVCNT\BIN\BSCMAKE under Windows NT).</li> <li>Modify the contents of the Menu Text field to read something like &quot;BSCMAKE with MAFXCWD&quot; .</li> <li> Specify the the following in the Arguments field: /o$PROJ /n *.SBR \*.sbr where is the directory where the SBR files are located. For example, if you followed the directions in step 1 and created the .SBR files for the medium model, debug, Windows, MFC library, you're SBR files will be located in the \MSVC\MFC\SRC\$MWD. </li> <li>Choose OK.</li></ol>

NOTE: The BSCMAKE command line includes the /n option switch. As the documentation describes, this switch prevents BSCMAKE from performing an incremental build that truncates all .SBR files to zero bytes. The /n option slows the .BSC build; however, it preserves the .SBR files for other projects to use. To speed performance, you may want to make a backup copy of the MFC Library .SBR files for repeated use and edit the Arguments field to remove the /n option switch to enable incremental builds.

You may want to modify the Arguments field to include the /Iu option switch. The /Iu switch instructs BSCMAKE to include all information that the source code defines but does not reference. By default, BSCMAKE does not include any symbols that are not referenced. Unfortunately, if you specify the /Zn compiler option in the Visual Workbench, VWB sets the Browser Information check box (and invokes BSCMAKE without specifying the MFC Library .SBR files). In Visual C++ version 1.0, the ability to browse MFC Library files and to browse symbols that are defined but not referenced are mutually exclusive.

To build the .BSC file for your project, build the project, then run BSCMAKE from the newly created option on the Tools menu.

IMPORTANT: You must close the browser window before you run BSCMAKE. BSCMAKE cannot create a new browser file unless the .BSC file is closed.</li></ol>

Important Notes

 * If you are running Windows with the Win32s DLLs, you will not be able to run BSCMAKE from the Tools menu. You must run it from the MS-DOS command line.
 * The .BSC file you create must not be moved to another directory otherwise the browser will not be able to find the source files.
 * Do not specify /A on the NMAKE command line if you don't have Microsoft Macro Assembler 6.1 or greater in your PATH. The /A option will do a &quot;rebuild all&quot; and will cause some assembler files (.ASM files) to be re-assembled. Of course, if you don't have the assembler, the makefile will fail.
 * For more information about BSCMAKE, view the BSCMAKE.WRI file located in the MSVC\HELP directory.
 * For more information about NMAKE, view the NMAKE.WRI file located in the MSVC\HELP directory.

Keywords: kbinfo kbmisctools kbcompiler KB98656

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.