Export (0) Print
Expand All

Include Headers and Libraries Manually

In this exercise, you will practice how to explicitly include headers and libraries into your project. This is also called loading DOM "raw". This example is functionally identical to the Load an XML DOM Object from an XML File (C/C++) example that follows it. The only difference is the way these headers and libraries are included.

This project uses or creates the following files.

Component

Description

Source: loadDOMRaw.cpp

Creates an XML DOM object and loads the resource file into the project's main directory.

Resource: stocks.xml

An XML data file.

Output

This is the output you should get when you build and run the loadDOMRaw project.

To create the loadDOMRaw Visual C++ Project

  • Create a C++ Win32 console application in Visual Studio 2008. For detailed instructions on how to do this, see Set Up My Visual C++ Project. Name the project LoadDOMRawProj.

To include headers and libraries manually

  1. Locate the SDK directory installed by the appropriate MSXML package. By default for MSXML 6.0, your directory will be C:\Program Files\MSXML 6.0, with subdirectories named inc and lib.

  2. Set up the include directory for Visual Studio. From the Tools menu, select Options. In the Options dialog box, expand Projects and Solutions. Select VC++ Directories. Select Include files in the Show directories for drop down box. Click the New Line button, and add a new line to the list of directories. Browse to the directory that contains the MSXML header file. For MSXML 6.0, by default, the directory is C:\Program Files\MSXML 6.0\inc. Click OK.

  3. Set up the lib directory for Visual Studio. From the Tools menu, select Options. In the Options dialog box, expand Projects and Solutions. Select VC++ Directories. Select Library files in the Show directories for drop down box. Click the New Line button, and add a new line to the list of directories. Browse to the directory that contains the MSXML libraries. For MSXML 6.0, by default, the directory is C:\Program Files\MSXML 6.0\lib. Click OK.

  4. Modify the project to link with the MSXML 6.0 library. In the Solution Explorer, right click on the project and select Properties. In the tree, expand Configuration Properties, and then expand Linker. Under Linker, click on Command Line. Enter msxml6.lib in the Additional options text box.

  5. Include the required MSXML header file by adding the following preprocessor directives to the source code:

#include <objbase.h>
#include <msxml6.h>

You need to include the appropriate header file for the version of MSXML that you want to use. For an explanation about which header files to include, and which libraries to link to, see Building MSXML Applications.

Next, we'll add the source code for this project.

Show:
© 2014 Microsoft