0

I am learning Direct3D from directxtutorial.com. I am including it through a preprocessor directive in the code below.

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib")
#pragma comment(lib, "d3dx10.lib")

This is not doing it, however. I am guessing it is because the library files aren't where its checking to find them. But could someone explain what's going on here? Thanks. The error message is: "Intellisense: could not open source file"

3
  • First of all, make sure you have the Windows SDK and that it's added to your search directories.
    – chris
    May 27, 2013 at 22:13
  • How do you add the Windows SDK to the search directory?
    – kkrenzke
    May 27, 2013 at 23:03
  • There should be an option somewhere in your project settings (or overall settings). This question might help.
    – chris
    May 27, 2013 at 23:11

1 Answer 1

3

You'll need to download and install the Windows SDK from this link.

Next, you'll need to configure your solution in Visual Studio to look for the appropriate files. This may be broken down in to two categories: Adding the include paths and Linking the libraries. Please take note of your Windows SDK directory. On my system, it is C:\Program Files (x86)\Microsoft SDKs\Windows\7.0A\.

Adding include paths

Visual Studio comes pre-packed with a subset of the DirectX header .h files, but the complete collection is available in WindowsSDKPath\Include.

Add this path to your project's additional includes:

  • Right click the project in the Solution Explorer, and choose Properties from the menu:
  • Configure the dialog box to affect both Debug and Release builds: Visual C++ Property Pages
    • Select the first drop-down and choose All Configurations.
  • From the tree on the left, choose Configuration Properties | C/C++ | General. This option will only appear if you have at least one .c or .cpp file in your project.
  • In the Additional Include Directories box, add the path to your Windows SDK Includes, for example: C:\Program Files (x86)\Microsoft SDKs\Windows\7.0A\Include.
  • Press Apply.
  • You're now ready to include the Direct 3D header files in your C++ code files, i.e. #include <d3d11.h>.

Linking the libraries

The Direct 3D libraries are contained in the WindowsSDKPath\Lib folder.

  • From the tree on the left, choose Configuration Properties | Linker | Input.
  • Tick the arrow on the drop-down of the Additional Dependencies field, choose Edit...
  • In the pop-up dialog, add the full paths to each library, with each path on its own line, like so: Linking Direct 3D Libraries
  • Press Okay, then press Apply or Okay.

Your project should now be configured to build Direct 3D Applications.

1
  • this appears to be a current link to the Windows 8 SDK. May 28, 2013 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.