News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Programming In VC++ - Developer Studio - Part III

Started by sivaji, Jan 10, 2008, 05:28 PM

Previous topic - Next topic

sivaji

Programming Stuffs in "VC++" - Technical Skills for INTERVIEW

Building a Project

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.

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.

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.


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).

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).
Am now @ Chennai