Preparing for Compilation

The samples included in this SDK use Microsoft® Visual C++® project files (MDP files) that describe the appropriate source files, project resources, and linker settings for each sample. However, you may need to make additional preparations to ensure that the samples compile and link properly, or you might need to prepare settings for a new project of your own. (For the samples, developers that use other compilers can reference the generic makefiles included for information about the required libraries, then configure their environment appropriately.) The information provided here applies to the DirectX samples and the DirectX applications you will create.

After opening a project file in Visual C++, you should verify some settings before trying to compile the application. The following descriptions are given in terms of the Microsoft Visual C++ 5.0 and 4.2 options. Previous versions of Microsoft Visual C++ and other compilers have equivalent settings. If you do not use these versions of Microsoft Visual C++, refer to the documentation provided with your development environment for information on changing these settings.

Note  The following discussion uses the default installation paths (C:\mssdk\include and C:\mssdk\lib) to describe file locations. Your installation paths might differ.

Include search paths

Make sure the search path for header files is correct, and that the directory for DirectX header files is the first path that the compiler searches. To check the include path, choose Options from the Tools menu, then select the Directories tab. The following dialog box will appear.

The topmost path should indicate the folder that contains the latest DirectX header files. The default path is C:\mssdk\include. If the path is not present, add it to the list and move it to the top of the search list by using the toolbar controls within the Directories tab.

Linker search paths

Check the search paths and search order that the linker uses to search for link libraries. The link search paths are also listed on the Directories tab; choose Options from the Tools menu, then select the Directories tab. When the dialog appears, choose the "Library files" option in the "Show directories for:" drop-down list box. The topmost path should be the folder that contains the latest DirectX link libraries. The default path is C:\mssdk\lib. (Borland link libraries are provided in the Borland folder within the default folder.)

Project link libraries

If you are using the provided sample project files, you shouldn't need to verify these settings, as they are specified with the provided project files. For new applications, choose Settings from the Project menu to make the following dialog box appear. (In Visual C++ 4.2, this is the Settings item on the Build menu.)

All DirectX applications should link to the Dxguid.lib include library, which defines the globally unique identifiers (GUIDs) for all DirectX foundation COM interfaces. (Alternatively, you can define INITGUID prior to all other include and define statements in a single source module.) In addition, verify that the application is linked to the appropriate standard DirectX link libraries. The following table shows the various DirectX foundation components that might be used, and the corresponding link libraries for those components.

Component Link Library (*.LIB)
DirectDraw Ddraw.lib
Direct3D Immediate Mode Ddraw.lib
DirectSound Dsound.lib
DirectInput Dinput.lib
DirectSetup Dsetup.lib
(All components) Dxguid.lib