Followers 0
• entries
557
1237
• views
420910

# Adding DirectX directories to Visual Studio

Followers 0

912 views

Another one of these "I'll link this entry from various threads" posts:

Sometimes when you install the DirectX SDK, it doesn't properly add the directories to Visual Studio, so VS can't find the DirectX headers and library files. The most common symptom of this is the compile error "Cannot open include file: 'd3d9.h': No such file or directory".

To add the headers and library files to Visual Studio (2005 or 2008, they're both the same), go to the Tools menu -> Options, then go to Projects and Solutions -> VC++ Directories. First, make sure the "Show directories for:" droplist in the top right is set to "Include files", and add the path to the DirectX SDK/Include directory, and make sure it's at the top of the list by clicking the black up arrow icon:

Next, change the "Show directories for:" droplist to "Library files", and add the path to the DirectX SDK/Lib/x86 directory. The additional x86 directory is important here, and if you miss it out, Visual Studio won't be able to find the library files:

If you're building for x64, then you'll want to change the "Platform" drop list to "x64" and add the DirectX SDK/Lib/x64 directory instead. If you're not sure what you want, then you probably want Win32 and the x86 directory.

After you've added those two directories, click "OK", then hit F5 to build and run your code again.

0
Followers 0

But what if you want to compile for x64?
0

Quote:
 Original post by Mike.Popoloski But what if you want to compile for x64?
Tough.

Ok, I'll edit it then [smile]. I was working on the assumption that most people who aren't sure how to set up the DirectX SDK directories won't be doing x64 compilation.
0

You might want to use $(DXSDK_DIR) instead of "C:\Program files\Microsoft DirectX SDK (March 2008)" as the DXSDK_DIR environmental variable should be created when you install the DirectX SDK. Might be a bit more useful for others with the SDK installed elsewhere :)  Forgot to say, great work on the tutorials so far, keep up the good work[/edit] 0 #### Share this comment ##### Link to comment Quote:  Original post by SuperRad You might want to use$(DXSDK_DIR) instead of "C:\Program files\Microsoft DirectX SDK (March 2008)" as the DXSDK_DIR environmental variable should be created when you install the DirectX SDK. Might be a bit more useful for others with the SDK installed elsewhere :)
I meant that the path you enter should be the path to wherever you installed the SDK. Personally, I think it's safer to use a direct path rather than an environment variable, since if the directories weren't added in the first place, there's a change the environment variables weren't set up properly either. It's just a little safer.

Quote:
 Original post by SuperRad  Forgot to say, great work on the tutorials so far, keep up the good work[/edit]
Thanks, I hope to get the next one up soon [smile]
0

Hi Steve. For VC++ 2010 (Express and Pro it seems), the VC++ Directories section in the preferences is gone, and the directories are now supposed to be set on a per-project basis. This can be resolved by following these steps. Also see this post and the replies to it for additional infos. I'm posting this in case you want to update this useful entry of yours to be more complete. Salutes.
0

## Create an account

Register a new account