How do I add DirectX SDK into Visual Studio 2012

Pages: 12
Hey, I've installed the DirectX SDK and it's all in there under
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\
and I also have Microsoft's Visual Studio Express 2012 compiler stored in
C:\Program Files (x86)\Microsoft Visual Studio 11.0\

But how do I impliment the DirectX SDK into the compiler so that I can simply include any directX files as I would with the files that are standard with windows... Such as the following #include <d3dx9.h> -- DirectX header
If you installed the SDK after the Visual Studio, it *should* be already configured.

You only need to:

#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib") 

If it still doesn't work, you should add include and library paths for every project (Or, if this feature is still available, adding them once and storing them life-time in a so called "Property Sheet", but I'm not sure about vs12)
My code does feature the set.
#include <d3d9.h> //Comes with VS
#include <d3dx9.h> //SDK only  //Error here: "Cannot open include file 'd3dx9.h': No such file or directory"
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib") 

But as you can see from the error I've commented in, this doesn't work.
Last edited on
Uhm, then you'll have to set up directories manually.
If you have property sheets in VS12 it's convenient for you to use them, it will be the same process but in another window.

Basically you should, either in the Project Properties or in the global Property Sheets, add the Include, Lib and Bin entries for the DirectX SDK.

Given "D3DSDKFolder" which is your base D3D SDK Folder, here in C:\Program Files\Microsoft DirectX SDK (version),

Include = D3DSDKFolder\Include
Lib = D3DSDKFolder\Lib\x64 for 64bit, D3DSDKFolder\Lib\x86 for 32bit
Bin = D3DSDKFolder\Bin (Not required)

As you can see it's no big difference from other libraries, you just setup the include and lib directories and you're done.
I'm not sure of why would you put Bin folder too, but I'm not sure of why you wouldn't put your Bin folder either.
Thanks for the help... Don't suppose you know how to get to these property sheets in VSE12?
I can tell in VS10, maybe the procedure is similar:

1. Open a project
2. View->Property Manager
3. You should have a tree view which shows up like this:

(Project Name)
--- Debug | Win32
   --- Microsoft.Cpp.Win32.user
   --- ...
--- Release | Win32
   --- Microsoft.Cpp.Win32.user
   --- ...

Right click, under "Debug | Win32", Microsoft.Cpp.Win32.user, and choose Properties.

The properties you set there will be your default properties for all your projects, under the Debug configuration.

Then proceed to do the same under "Release | Win32", which will apply the changes to the Release configuration.

Just in case, once you've right-clicked a Microsoft.Cpp.Win32.user, to add paths, go to:

Common Properties
----VC++ Directories

This should be your screen:

Now, I've highlighted some things.

This is the italian version but you should be able to find out by yourself the names.

Row | Usage
A   | Bin Paths
B   | Include Paths
C   | Lib Paths

When you click on the RIGHT column (Highlighted in red), a Dropdown options list comes out clicking on the button (Highlighted in green).

Click on Edit.

You can now add each line for each entry you want to add using the New Line button (also CTRL+INS).

This is obviously for VS10.
Last edited on
Thanks again!
you're a great help!
Last edited on

Got it working! Thanks so much!!
Wait, I'm getting problems to do with "unresolved externals" now when using functions in Direct3D such as D3DXMatrixLookAtLH(...) and D3DXMatrixRotationY(...).

In the properties sheet for Microsoft.Cpp.Win32.user there are options for "Executable Directories", "Include Directories", "Reference Directories", "Library Directories", "Library WinRT Directories", "Source Directories" and "Exclude Directories"...
I've added to the Include and Library directories... Anything I'm missing from here which are needed?
Well, you're not linking your project with D3Dx9.lib
( #pragma comment(lib, "d3dx9.lib") )

Besides the fact you can notice its library from "D3DX" prefix, here its library is explicitly d3dx9.lib:
Last edited on
In the project I'm using the following:
#include <d3d9.h>
#include <d3dx9.h>
#include <Windows.h>
#include <windowsx.h>
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib") 
Oh, I forgot.
Try to add dxguid.lib.
Oh wait... Do I need #include <d3dx9math.h> ?

The same link as you posted just above says that D3DXMatrixRotationY(...); has requirements of d3dx9math.h and d3dx9.lib
Last edited on
No, it gets included from d3dx9.h. And the file is properly included as non-linking gives Unresolved External, and non-inclusion gives Undefined/Undeclared identifier.
Last edited on
dxguid.lib didn't work :(
This is very weird.
If you're compiling for 32-bit, are you sure you set up the 32-bit lib directory of the DirectX SDK?

Because this error sometime happens when you compile a 32bit exe with 64bit lib's.
I'm running on 64bit so I really hope not :D
Do you know how to take a look at the composer's macros in VS12, I'm just wondering if for some reason my compiler is running in 32bit therefore wants the 32bit library and not the 64bit library which I've given it.
I say this because I've seen a lot of functions used as macros to link to a "recommended" function, so the macro change what you're actually using depending on other definitions.
By default all projects compile for 32-bit machines.

To compile for 64-bit (Your executable will NOT be suitable for 32bit systems after this!) go in your projects settings, Linker->Advanced, Destination Computer, and change from "MachineX86" to "MachineX64".

(This is translated and taken from vs10 as always)

It does not rely on macros.
Last edited on
Right, thanks!
And failing that I have also found this after a bit of searching:

Maybe this is the problem! Which version of Visual studio do you use? You can't compile you application under the x64 profile in the express editions. And if you use a pro version, your project configuration needs to be x64, too.
I've got a x64 CPU, too, but because of my Express edition I can't compile anything for x64.


In project properties >> configuration properties >> linker >> input under additional dependencies make sure you have d3dx9.lib . My list of additional dependencies looks as follows:

I really hope that changing my settings to x64 will work but failing that I do believe if I link to the x86 library instead, then my app will build (unfortunately in 32bit though, oh well it could be worse).

There's also someone with the same problem here
Who has to change to the x86 libraries for it to compile... So I THINK I have my answer:
Set to 64bit application or use x86 libraries
Last edited on
Pages: 12