The Visual C++ Developer Studio application is the centerpiece of the Visual C++ development system. It offers a variety of features, provides access to most Visual C++ development system components, and also provides a front end for other Microsoft development products, such as Microsoft Test, Microsoft SourceSafe, or the Developer Library CD-ROM.
This new Developer Studio (Figure 1.1) sports a much-improved source editor, an excellent resource editor, an integrated help system, project build options, and access to other integrated components such as the AppWizard, the ClassWizard, the integrated debugger, and the profiler.
Figure 1.1. The Developer Studio.
Although the Developer Studio represents the interface of choice for accessing the features of Visual C++, the C/C++ compiler and other components of the development system can also be used from the command line. In some cases, such as when compiling simple test programs, it is actually easier to do than to use the graphical interface.
In this chapter, we begin our tour of Visual C++ by reviewing the Developer Studio and its basic features. In the second half of the chapter, we examine the use of Visual C++ command-line tools.
The Developer Studio offers a series of interfaces for projects, source files, resource file components; and a series of tools for building, running, and testing applications. It also offers integrated access to the Visual C++ help system and other media titles, such as the Microsoft Developer Library.
For those of us familiar with earlier versions of Visual C++, perhaps the most striking new feature in Version 4 is the new project workspace window (Figure 1.2).
Figure 1.2. The Project Workspace in ClassView.
In addition to the old-fashioned presentation of a project as a collection of source files, you are now provided with two new ways of looking at a project. In ClassView, the classes that comprise a project, their member functions and variables, and the project's global variables and functions are presented; in ResourceView, the project's resource file components can be viewed.
The ClassView window provides a hierarchical representation of classes when they are embedded in other classes. It also uses different symbols to identify private, protected, and public class members.
Apart from being pretty, the ClassView is also useful. Double-clicking on any item opens the appropriate file for editing and positions the text cursor on the item. For example, double-clicking on a class name opens the file containing the class declaration and positions the cursor at the beginning of the declaration. Double-clicking on a member function name opens the appropriate implementation file and positions the cursor at the beginning of the function definition.
The FileView window presents a more traditional view of your project. This view lists all your project source files and dependencies. Double-clicking on any file opens the file for editing.
Often you add new files to a project implicitly, such as when you create a new class through ClassWizard. However, if you need to explicitly add a new file to your project, use the Files into Project command from the Insert menu.
The Project Workspace is not restricted to a single project. You can use the Project command from the Insert menu to insert additional projects into a workspace.
You can add new projects to the workspace as top-level projects or as subprojects. The major distinction is that a subproject participates in the build process; when a project with subproject is rebuilt, its subprojects are rebuilt first.
The use of projects and subprojects allows for a variety of scenarios. For example, a project may have subprojects representing dynamic link libraries. Two top-level projects may represent a client and a server application.
A project configuration defines how the executable program or library that a project defines is built. When you create a project through AppWizard, a set of default project configurations is also created. For example, if you create a project for the Win32 Intel platform, AppWizard creates two configurations: one for debug and one for release build. Later, project configurations can be added or removed using the Configurations button from the Build menu (Figure 1.3).
Figure 1.3. The Configurations dialog.
The settings for a specific configuration or set of configurations can be modified using the Settings command in the Build menu. We return to the Project Settings dialog later in this chapter when we discuss building a project.
The new Visual C++ source editor offers familiar features, such as drag and drop editing and syntax coloring. It is also extensively customizable.
The editor can be made key-compatible with the Brief or Epsilon editors. Key settings can also be customized by the Customize command from the Tools menu and selecting the Keyboard tab in the Customize dialog (Figure 1.4).
Figure 1.4. Keyboard customization.
The preset Brief or Epsilon editor configurations can be invoked through the Options command in the Tools menu. In the Options dialog, select the Compatibility tab. In the Recommended options drop-down box, select the desired editor emulation. The four choices include the default Developer Studio configuration, the Visual C++ 2.0 compatibility mode, and the Epsilon and Brief emulations (Figure 1.5).
Figure 1.5. Selecting editor emulations.
The integrated resource editor in Developer Studio provides a comprehensive editing facility for all types of resources. This includes the new toolbar editing facility, as well as the capability to insert and edit custom resources.
Resource editing begins with the ResourceView in the Project Workspace window (Figure 1.6). This window provides a view of all the elements in a project's resource file.
You can insert a new resource by selecting the Resource command from the Insert menu. This command displays a dialog (Figure 1.7) where you can select the type of the new resource. In addition to predefined types, user-defined types also appear in this dialog. You can use this dialog to insert a blank resource; however, when inserting a cursor or a dialog, you can also use a predefined template as the basis for your new resource.
Figure 1.7. Inserting a new resource.
Accelerators (Figure 1.8) are keyboard shortcuts that generate WM_COMMAND messages; the same type of messages as those generated by menu commands and dialog controls. A project can have several accelerator tables; for example, if it uses multiple menus, it may use different accelerator tables for those. To edit a specific accelerator key, double-click the key in this window to invoke its properties.
Figure 1.8. Editing an accelerator table.
The bitmap editor (Figure 1.9) enables you to create monochrome or color bitmaps. A variety of graphics tools can be used when drawing the bitmap. Use the mouse to select the desired tool and the foreground and background colors, and then draw the bitmap.
While a bitmap is displayed on screen, a new menu, the Image menu, becomes available in the Developer Studio menu bar. Commands in this menu can be used to manipulate the bitmap; in particular, the Grid Settings command can be used to set up a grid of guide lines. Use this grid when creating a bitmap that consists of many small pictures.
Editing a cursor (Figure 1.10) is very similar to editing a bitmap. However, for cursors, the color palette also contains two special "colors"; one that corresponds to the background color, and another that corresponds to the inverse background color.
Figure 1.10. Editing a cursor.
You can also specify a cursor's hotspot. The hotspot is the position in the cursor image that Windows uses to track the cursor and to generate cursor-related events.
The dialog editor (Figure 1.11) is the tool for editing dialog templates. Editing a dialog template consists of selecting controls from the control palette and placing them on the template, and specifying dialog and control properties.
Figure 1.11. Editing a dialog.
The dialog control palette supports all standard controls as well as most Windows 95 Common Controls. It also provides a tool for placing OLE controls in your dialog.
While a dialog is being edited, a new menu, the Layout menu, is displayed by the Developer Studio. This menu offers several commands that help to adjust the placement of controls in a dialog template. Among these is the Guide Settings command. This command invokes a dialog (Figure 1.12) where you can specify rulers, guides, and grid settings to assist you during dialog template editing.
Figure 1.12. Guide settings for dialog editing.
Editing an icon (Figure 1.13) is very similar to editing a cursor. The only notable difference is the lack of a hotspot in icons. When creating an icon, you may wish to create several versions of the icon. For example, compatibility with Windows 95 requires that your application register a 16x16 icon in addition to the standard, 32x32 icon.
Editing menus is easy and straightforward using the graphical menu editor (Figure 1.14). To insert a new item in either a horizontal menu bar or a vertical popup menu, simply grab the blank item at the end of the menu using the mouse and move it to the desired position, then type the menu text. The menu editor will automatically assign a symbolic identifier to the menu based on the text you typed; however, should you desire another identifier, you are free to change it through the menu item's property sheet. Through this property sheet, you can also adjust the initial settings of a menu item.
To insert a separator, create a blank menu item, and check the Separator box in the item's property sheet. To insert a menu item that has a submenu, create the item and check the popup box in the item's property sheet.
For every menu item, you can also prescribe a prompt string. The prompt string consists of two parts, separated by the newline (\n) character. The first part of the prompt string appears in the status bar of standard MFC applications; the second part is used for tooltips. The string you specify as the prompt string is actually deposited in your application's string table, with an identifier that matches the identifier of the menu item.
A string table (Figure 1.15) is a collection of text strings used in your application. The major advantage of using a string table is that it lets you use the resource file as the depository of all language-dependent elements of your application. If such an application is localized in a foreign language, only the resource file needs to be changed and relinked; it is not necessary to modify and recompile the application's source code.
Figure 1.15. Editing a string table.
The MFC Framework uses the string table extensively for MFC text constants. To edit a string in the string table, simply double-click the item and modify it as needed using the property sheet that is displayed. You can add a new string to the table by double-clicking the blank entry at the end of the list.
A new feature in Visual C++ 4 is the toolbar editor (Figure 1.16). Previously, it was necessary to edit toolbars as bitmaps and manually adjust corresponding structures in your application's source codea procedure that was cumbersome and error-prone. With the new toolbar editor, you can edit toolbar buttons, assign command identifiers, and prompt strings all within the resource editor.
Figure 1.16. The toolbar editor.
To add a new toolbar button to the toolbar, grab the blank button at the end of the toolbar using the mouse and drag it to the desired position. To remove a toolbar button, select it with the mouse and drag it out of the toolbar window altogether (pressing the Delete key will only erase the button bitmap instead of removing the button from the toolbar altogether).
You can assign a symbolic identifier and a prompt string to a toolbar button the same way you assign them to menu items. Note that in order for a toolbar button to be functional, it is not necessary to have a menu item with the same identifier. In other words, your program may have commands that are accessible from a toolbar only.
The version information resource (Figure 1.17) identifies the current version of your executable program or library file. This version information is used by software installation functions; it is also displayed by the Windows 95 Explorer when QuickView is selected.
Figure 1.17. The version information resource.
Lastly, the resource editor can also edit custom resources. A custom resource type is identified by a type name enclosed in double quotes. Custom resources are edited through a binary editor (Figure 1.18); more likely, they are resources that are created using an external tool. A good example for a custom resource is a multimedia sound or video file.
Figure 1.18. Binary editor for custom resources.
The Developer Studio supports multiple language resources in the same resource file. To specify the language for a resource, select the resource identifier in ResourceView, and invoke the Properties command from the Edit menu (Figure 1.19). Note that the resource file can contain several localized versions of the same resource sharing the same identifier. Compilation of localized resources is controlled through preprocessor directives in the resource file. You can utilize localized resources in language-specific build configurations by adding the appropriate preprocessor definitions in the configuration's resource settings in the Project Settings dialog.
Figure 1.19. Setting the language for a resource.
The Developer Studio supports resource templates. Resource templates are predefined resources that are used as templates when new resources are created. For example, when you select the Resource command from the Insert menu, in addition to the default dialog, you can select from a variety of additional dialog templates (Figure 1.20).
Figure 1.20. Using resource templates.
To create custom resource templates, copy the desired resources to a new resource file, and save the file as a resource template file in your msdev\template directory using the Save As command in the File menu. The new templates will appear the next time you invoke the Resource command from the Insert menu.
Building a project means recompiling and relinking the project's components to produce the project's target executable or library file. Every project has a make file associated with it. When a project is being rebuilt, dependencies in the project's make file are evaluated, and components that are affected by changes are recompiled and relinked. To rebuild a project, select the Build command from the Build menu. Incidentally, you can also rebuild a project using the command line nmake.exe utility; to do so, enter the project directory and type nmake /f projname.mak where projname represents your project's name.
The Rebuild All command in the Build menu rebuilds all project components unconditionally; it does so by removing all files that are the results of previous builds and then reevaluating the project's make file.
The Developer Studio provides an interface where a multitude of project build options can be specified or changed. To invoke this interface, select the Settings command from the Build menu (Figure 1.21). On the left side of the Project Settings dialog, you see the list of project configurations; on the right side a property sheet provides access to many project options.
Figure 1.21. Project Settings: General options.
When you initially invoke this dialog, all project configurations are selected in the left side. Correspondingly, any settings that are displayed on the right side are those that are common to all configurations. If you wish to alter settings that are specific to one configuration or another, select the desired configuration first, before making any changes on the right side.
In addition to being able to specify configuration-specific settings, you can specify settings that apply to individual files. To do so, expand the desired configuration by double-clicking its title. The files that comprise that configuration are displayed, and by selecting a specific file, you can alter settings for that specific file. Note that the set of tabs shown on the right side of the dialog changes to reflect your selection; for example, if you select a C++ source file, only the General and the C/C++ tabs will be available.
The first property page on the right side of the Project Settings dialog is the General page. In this page, you specify the MFC Library you wish to link your project with; you can also specify separate directories where intermediate files and output files are deposited.
The next property page shows debugging options. Figure 1.22 shows the Debug property page; or, to be more precise, the first subpage of this property page. Using the Category control, you can select either the General category, shown in Figure 1.22, or the Additional DLLs category. Yes, this is property pages within property pages.
Figure 1.22. Project Settings: Debug options.
In the General subpage, you can specify the debugging environment in which your program will run. Of particular importance is the executable filename field. Why would you want this to have anything other than the name of the program you are currently debugging? The answer is simple; by specifying an executable in this dialog, you can debug DLLs and other components that are not directly executable from the command line.
For example, if you use Visual C++ to develop a MAPI transport provider, specify the name of the MAPI spooler, mapisp32.exe, as the name of the executable, because it is this program that would load your transport provider DLL. If you are developing an OLE control (OCX file), specify an OLE control container application, such as the tstcon32.exe application that comes with Visual C++, as the executable.
The third property page in the Project Settings dialog, the Custom Build page, enables you to add customized build steps to a standard make file. For example, if your project contains a grammar specification file that is to be processed by the yacc parser generator, you may wish to add a custom build step for your grammar file, gram.y, as shown in Figure 1.23. Note that if your custom build step produces files that further need to be processed, you must also include those files in your project; in the example shown in Figure 1.23, this means that the file gram.c had to be added to the project separately.
Figure 1.23. Using Custom Build options.
The fourth property page enables you to set several compiler options. This property page has several subpages, again selectable using the Categories field.
Of particular interest is the Precompiled Headers subpage, which enables you to specify how the compiler creates and uses precompiled header (PCH) files during compilation. The use of precompiled headers is of great importance, as it enhances the compiler's performance very significantly.
Basically, there are two options; one is self-evident, the other is not. If you select the Automatic use of precompiled headers option, the compiler will look for and identify common headers in your project's files, and generate and use a precompiled header accordingly.
However, automatic precompiled headers are not what AppWizard-generated projects use. Instead, in those projects, the generation and use of precompiled headers is prescribed explicitly. If you wish to copy this behavior, it is important to realize that you should pick one file in your project (for example, stdafx.cpp) that the compiler uses to create the precompiled header (Figure 1.24); all other source files should be set to use the precompiled header (Figure 1.25).
Figure 1.24. Compiler options: creating a precompiled header.
Figure 1.25. Compiler options: using a precompiled header.
The Project Setting dialog's fifth property page, the Link page, provides access to various link options. This is the third property page with several subpages.
The sixth property page in this dialog, the Resources page, contains fields that control the building of the project's resources.
The seventh property page, OLE Types, control how OLE type library files (TLB files) are constructed from Object Description Language (ODL) files. This page is relevant for OLE automation servers and OLE control projects.
The eighth and last property page controls the building of a browse information file. If you wish to use the browsing features of Developer Studio, make sure that the Build browse info file box is checked (Figure 1.26).
Figure 1.26. Building the browse information file.
A brand new feature of Visual C++ Version 4 is the built-in InfoViewer. The InfoViewer is a Developer Studio component for reading Microsoft MediaView titles (MVB files); most notably, the online documentation that comes with Visual C++ itself.
When Visual C++ 4 is installed on a system on which the Microsoft Developer Library was installed previously, the Visual C++ installation program will add the Developer Library media title to the set of titles that can be browsed using the InfoViewer. Unfortunately, no easy-to-use facility exists for adding other titles.
In my experimentation with Visual C++, I discovered how new titles can be added to the InfoViewer; however, this method, apart from being completely undocumented, requires manually altering Registry contents, so use at your own risk! I used this method successfully to add the MAPI SDK documentation, available for downloading from Compuserve, to the set of media titles that can be browsed using InfoViewer.
Essentially, adding a new title requires adding several subkeys and values under the HKEY_CURRENT_USER\Software\Microsoft key in the Registry. The subkeys and values that I needed to add for the MAPI SDK documentation, stored in the file f:\msdn\mapisdk.mvb, are as follows:
InfoViewer\DocSets\MAPISDK\mapisdk.mvb\MAPISDK=1 InfoViewer\Series\MAPISDK\Title="mapisdk.mvb" InfoViewer\Titles\MAPISDK.MVB\aux="MAPISDK.AUX" InfoViewer\Titles\MAPISDK.MVB\Localdir="F:\MSDN" InfoViewer\Titles\MAPISDK.MVB\Path="F:\MSDN\" InfoViewer\Titles\MAPISDK.MVB\Series="MAPISDK" InfoViewer\Titles\MAPISDK.MVB\Title="MAPI Documentation"
This method works well for titles that consist of a single MVB file. I have not experimented with titles consisting of multiple MVB files.
Note once again that all the affected Registry keys are under HKEY_CURRENT_USER. Even though there is an InfoViewer subkey under HKEY_LOCAL_MACHINE, you should not alter that key or its subkeys in any way.
If your effort is successful, the new title shows up in the InfoViewer toolbar (Figure 1.27).
Figure 1.27. The InfoViewer toolbar with a manually added title.
Hopefully, future versions of Visual C++ will make it easier to add or remove InfoViewer titles.
To browse an InfoViewer title, select the InfoView in your Project Workspace window (Figure 1.28). If you have no project open, this is the only view that is visible in that window. To select a specific article, double-click on its title; the InfoViewer will display the article together with a toolbar that contains several navigation buttons.
You can set a variety of options for the InfoViewer through the Options command in the Tools menu. InfoViewer search options can be selected through the InfoViewer tab in the Options menu (Figure 1.29); the appearance of text in InfoViewer windows can be specified using the Format tab.
Figure 1.29. InfoViewer options.
The Developer Studio, in addition to providing the features discussed in this chapter, also provides an integrated interface to some of the major Visual C++ tools.
The AppWizard is a tool for generating skeleton applications. Through the AppWizard, application skeletons for OLE component servers, containers, ODBC and DAO applications, OLE automation servers, OLE controls, and more can be created.
The ClassWizard is perhaps the most often used Visual C++ tool; in addition to being a browser tool for CCmdTarget-derived classes, it can also be used to create new classes and add member functions and variables to existing classes.
The source browser provides the capability to review definitions and references of symbols in your application.
The integrated debugger is a highly powerful symbolic debugger for C and C++ applications. It can be used to debug Win32 executables as well as dynamic link libraries.
The Visual C++ Profiler is a performance analysis tool. With the help of the Profiler, you can easily determine which areas of your application represent performance bottlenecks.
The Visual C++ development system also includes a set of extra tools that are available from the Tools menu. These tools are stand-alone applications that help you exercise and test programs and components that you develop.
The first of these tools is Spy++, a new application for snooping messages (Figure 1.30). With Spy++, you can display all messages sent or posted to selected windows; you can also specify a subset of messages that you are interested in. Spy can also display the hierarchy of current processes, threads, and windows owned by threads; this way you can select windows for tracing that are normally hidden and could not otherwise be selected on the screen.
The MFC Tracer application (Figure 1.31) enables you to turn on various MFC trace flags. With these flags on, MFC applications that have been compiled with the debug version of the MFC Library send a variety of debugging messages to debugging output.
The Register Control option invokes the regsvr32.exe program. This program is used to register an OLE control. It does so by loading the control DLL (the OCX file) and calling its DllRegisterServer exported function.
The OLE Control Test Container (Figure 1.32) is useful for testing the behavior of OLE controls. You can use this application to insert any registered OLE control, invoke the control's properties and methods, and trace control notifications.
Figure 1.32. OLE Control Test Container.
The OLE Object View application (Figure 1.33) is a testing tool that enables you to view the all installed OLE types, their properties, interfaces, version numbers, type libraries, and more.
There is a series of additional tools that are not included in the Developer Studio Tools menu. These include DDESpy, a utility to monitor Dynamic Data Exchange activity; the PView process viewer utility; ZoomIn, a utility to capture and enlarge portions of your Windows screen; and WinDiff, a file and directory comparison utility.
The Developer Studio, in addition to presenting an excellent interface to many Visual C++ features, also provides integration with other Microsoft development tools. One, I already mentioned; through InfoViewer, the Developer Studio can be used as the reader for the Microsoft Developer Library.
Another product that the Developer Studio provides integration for is Microsoft FORTRAN. If you have Microsoft's FORTRAN PowerStation installed, you can use the Developer Studio to create and build both C++ and FORTRAN projects.
The Developer Studio can also be used in conjunction with Microsoft Test, Microsoft's scripting tool for application testing.
The Developer Studio is also integrated with Microsoft's new source code control system, Visual SourceSafe. If you have Visual SourceSafe installed, a series of additional menu commands appears, providing access to source code control functions.
Is using the wonderful tools of Visual C++ from the command line a heresy? I don't think so. Often it is much simpler to type cl myprog.c than to go through the elaborate process of setting up a Visual C++ project, adding your files to it, and recompiling and running your project through the graphical interface.
When would you use the command-line tools? I would like to offer some simple rules of thumb: If your project is complex enough to require a make file, use the graphical interface. If you wish to debug your program interactively, use the graphical interface. If your program has a resource file, use the graphical interface.
However, if you just want to key in a 10-line example from a textguide and quickly test it, you may find it more convenient to do so at the command line. In fact, many simple examples in this guide can easily be compiled from the command line (of course, nothing prevents you from loading them as Visual C++ projects).
Many command-line tools depend on the appropriate Visual C++ directories being on the path and on other environment variables being properly set. If you are using Windows NT as your development platform, the Visual C++ installation program offered you the option to register these environment variables so they automatically appear in DOS sessions. If you are using Windows 95, you must run the vcvars32.bat batch file (found in your msdev\bin directory) to register these variables before you can use the command-line tools. Note that it may be necessary to increase the environment size for DOS windows (select the Properties command from the DOS window's control menu and use the Memory tab) before vcvars32.bat can be successfully run.
The vcvars32.bat batch file also accepts an optional parameter that specifies the target system (X86, Motorola 68k, or the PowerPC). Use this parameter to specify a target environment other than Intel X86 on systems with a Visual C++ cross-development edition installed.
The environment variables set by vcvars32.bat include the following: INCLUDE specifies the location of include files for the compiler; LIB specifies the location of library files for the linker; and PATH specifies the location of Visual C++ executables (in addition to any other directories that you may have included there). There are several other environment variables interpreted by the various utilities; for example, the compiler, cl.exe, reads the contents of the CL environment variable for additional command-line options, while the linker reads additional command-line arguments from the LINK environment variable. All Visual C++ programs make use of the TMP environment variable to find the location for temporary files.
The Visual C++ compiler is invoked from the command line using the cl command. If invoked with the name of source files on its command line and no other parameters, it compiles those source files, then invokes the linker to create an executable.
If you specify the name of object files or library files on the command line, those will be passed to the linker. For example, consider the following compiler command line:
cl hello.c myfunc.obj mylib.lib
In response to this command, the Visual C++ compiler will compile hello.c, then invoke the linker with hello.obj and myfunc.obj. It will also pass the name of the library file mylib.lib to the linker, which will use this file in addition to any default libraries when searching for library functions.
If you wish to compile a file but not produce an executable, use the /c option:
cl /c hello.c
Note that using the forward slash or the dash is equivalent when specifying command-line options.
Some other useful options include /MT (link with the multithreaded version of the run-time library), /MD (link with the DLL version of the run-time library), and /LD (create a DLL). Of course, the compiler has a myriad other options (type cl /? to find out just how many). However, if you need to specify complex options, you're probably better off compiling from the Developer Studio.
The object files produced by the Visual C++ compiler are of the Common Object File Format (COFF).
The linker, link.exe, is a tool that accepts Common Object File Format (COFF) files, 32-bit Object Module Format (OMF) files, library files, and other input files and produces Win32 executable files or dynamic link libraries. In its simplest form, the linker is invoked with the name of an object file on the command line:
link hello.obj
The linker accepts many command-line options. Among these is the /subsystem option that specifies the type of the resulting executable. For example, specifying /subsystem:windows forces the output file to be a Windows executable. However, often it is not necessary to use this option; the linker defaults to /subsystem:console if the object files contain a definition for the main (or the wide-character version, wmain) function, and to /subsystem:windows if a WinMain (or wWinMain) function exists.
If you wish to produce a dynamic link library instead of an executable file, use the /DLL option. This option is automatically specified when the linker is invoked by the compiler, and the compiler was run with the /MD option.
Many other options control how input files are processed, what default libraries are used, and the type and contents of output files. In additional to executables, the linker can also produce debugging files (such as map files); you can also specify whether the executable is to include debugging information or not.
The library manager, lib.exe, is used to create libraries of COFF object files. It can also be used to create export files and import libraries for DLLs.
In its simplest form, lib.exe is invoked with a series of object filenames on its command line. It uses the base name of the first object file as the base name of a library file, and creates (or updates) a library consisting of the object files on its command line. The name of the output file can be overridden using the /OUT option.
If you wish to later remove the contents of an object file from the library, use the /REMOVE option. The /EXTRACT option can be used to extract the contents of the object file into a separate file.
To use the library manager to create an export file and an import library, use the /DEF option. Note that you rarely need to use this option, as the linker usually automatically creates the export file and the import library. Using the library manager is only required to resolve a situation when a program exports to, and imports from, the same library.
The program maintenance utility, or make tool for short (nmake.exe), is used to evaluate dependencies in make files and invoke the appropriate commands to generate targets. For example, a simple make file may look like this:
test.exe: test.obj link test.obj test.obj: test.c cl /c test.c
In all make files, the make tool evaluates targets in the order of their dependencies and updates all targets if they are older than any of their dependencies.
In addition to targets and dependencies, make files can contain many additional features, including macros and inference rules. These features render make files a formidably powerful and versatile tool.
Important options for nmake.exe include /a (specifying that all targets should be rebuilt unconditionally), /n (specifying that the make tool should only display, but not execute, commands), and /f (specifying the name of a make file).
Other command-line tools that ship with Visual C++ include rc.exe, bscmake.exe, dumpbin.exe, aviedit.exe, and editbin.exe.
The resource compiler, rc.exe, can be used to compile resource files and prepare them for linking with your project's object files. The resource compiler accepts the name of a resource file (with the .rc extension) and optional switches on the command line. Switches include /d (to define a symbol for the preprocessor), /fo (to specify the name of the output file), and /v (for verbose output). To obtain a complete list of command-line options, run rc.exe with the /? option.
The browse information maintenance utility, bscmake.exe, is used to create browse information (BSC) files from SBR files created during compilation. Browse information files can be viewed from the Developer Studio using its browsing facilities.
The binary file dumper, dumpbin.exe, displays information about COFF object files.
The aviedit.exe program is a simple tool to edit AVI files intended for animation controls. Use this tool to create an animation file from a series of bitmaps.
The binary file editor, editbin.exe, can be used to view and modify certain properties of COFF object files. Among these options is the ability to change a file's base address, the default heap size, and the default stack size.
The Microsoft Developer Studio is the centerpiece of the Visual C++ development system. It provides a series of different views on your projects through the Project Workspace windows; through this window, a project's class structure, files and dependencies, and resource file components can be examined.
A project workspace may contain one or more top-level projects; each project can have several subprojects, which can further be nested. For each project, Developer Studio maintains a series of configurations; a project configuration consists of settings used to rebuild the project. For example, when you create a new project using the Intel version of Visual C++, by default two project configurations (a debug and a release configuration) are created.
Source files in a project can be edited using the Developer Studio's customizable editor. Resource file components can be edited using the built-in resource editor; these components include accelerator tables, menus, dialogs, toolbars, icons, cursors, bitmaps, string tables, and custom resources.
Project settings can be modified using the Settings command in the Build menu. The Project Settings dialog is a complex dialog with eight property pages and several subpages. Settings for all configurations, specific configurations, a subset of files, or individual files can be specified or altered using this facility. Settings categories include the General, C/C++, Linker, Debug, Resource, OLE Types, Custom Build, and Browse Info categories.
Another useful Developer Studio facility is the InfoViewer; this facility provides access to MediaView titles, such as the Visual C++ on-line documentation or the Microsoft Developer Library.
The Developer Studio is also integrated with tools such as the AppWizard, ClassWizard, the integrated debugger, profiler, and source browser.
Many Visual C++ components can be used from the command line. For example, a basic Hello, World program can be compiled by typing cl hello.c. Other command-line tools include the linker, library manager, and the program maintenance utility (make tool).