Building SDK Samples

This topic discusses how you can:

Open an SDK Sample Within Visual C++

Build an SDK Sample from the Command Line

Fix an SDK Sample that Fails to Build

Open an SDK Sample Within Visual C++

There are two ways you can open an SDK sample project in Visual C++: by using the .dsp file or by using the MAKEFILE.  If an SDK sample does not have a .sdp file, then it will have a MAKEFILE.

Note   Some SDK samples contain version 5.0 Visual C++ .dsp and .dsw files.  These project and workspace files can be used in Visual C++ 6.0.  However, when you open the file, you will be prompted to confirm its conversion to the Visual C++ 6.0 format.  Also note that some samples will generate warnings when you build the project.

To open a sample in the development environment using the .dsp file

  1. Select Open Workspace from the File menu.

  2. Make sure the Files of type list box is set to Projects (.dsp).

  3. Locate and open the .dsp for the sample.

When you open a .dsp file for a sample that also has a .dsw file, Visual C++ will attempt to open the .dsw file.

To open a sample in the development environment using MAKEFILE

  1. From the File menu, click Open Workspace.

  2. Locate and open the MAKEFILE you want to build.

  3. Click Yes to the message that asks if you want to proceed.

  4. Select the platforms supported in the MAKEFILE.

  5. From the Project menu, click Settings.

  6. Type the name of the sample's executable name in the Output file name box of the General tab and, for debug builds, type the sample's executable name in the Executable for debug session box in the Debug tab. If you do not know the sample's executable name, you can either look in the MAKEFILE and search for the -out string or you can click Build Makefile.exe from the Build menu and then inspect the sample directory to see which executable has been created. Be aware that not all samples output a .EXE; for example, a sample might output a .dll.

  7. From the Build menu, click Execute Makefile.exe.

For more information on NMAKE and the commands in a MAKEFILE, see the NMAKE Reference.

Build an SDK Sample from the Command Line

Each SDK sample comes with a MAKEFILE. MAKEFILEs are designed to run at the command prompt.  See Open an SDK Sample Within Visual C++ for information on how to build a project's MAKEFILE from the development environment.

To build a sample from a command line in a command prompt window

  1. Run the Vcvars32.bat file that Visual C++ installs at Microsoft Visual Studio/VC98/bin.

  2. Change to the subdirectory that contains the MAKEFILE.

  3. Make sure all existing files that the MAKEFILE will write to are writeable. Use attrib -r *.* to make all files writeable.

  4. Issue the nmake command. NMAKE will look in the current directory and execute the MAKEFILE.

Fix an SDK Sample that Fails to Build

If you encounter an error when you build an SDK sample at the command line or from with Visual C++, a possible cause is that all the files necessary for building the sample are not present.  Inspect the sample's MAKEFILE for any file dependencies and then check your drive to ensure that all the required files and subdirectories are present.  For example, if there are more than one download link in a sample abstract, you must not change the download path, which displays when you click a download link, beginning with the sdk subdirectory.

If you determine that one or more files or directories are not on your local machine, you will need to copy the files from the MSDN CD that holds the Visual C++ samples.