# cant use directx in visual studio

This topic is 3856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Everytime I try to compile my program that uses DirectX, it wont compile :(. I'm completely new to using DirectX in programming. Someone help me please, thanks in advance!
------ Build started: Project: wndprogtest, Configuration: Debug Win32 ------
wndprogtest.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
C:\Documents and Settings\Matt\Desktop\wndprogtest\Debug\wndprogtest.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Matt\Desktop\wndprogtest\wndprogtest\Debug\BuildLog.htm"
wndprogtest - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

##### Share on other sites
It sounds like you're new to using API's in general ;)

You've got a classic linker error there - after compiling (it did compile successfully if it's up to the linking stage), the linker has to put all the bits of compiled code together, including any API's that you're using.
In this case, the linker is telling you that it can't find the DirectX files that it needs.

Go into the properties of your project, then into the Linker section, and then the "Additional Dependencies" field. Add d3d.lib and d3dx.lib to this field.

##### Share on other sites
------ Build started: Project: wndprogtest, Configuration: Debug Win32 ------
Compiling...
wndprogtest.cpp
LINK : fatal error LNK1104: cannot open file 'd3d.lib'
Build log was saved at "file://c:\Documents and Settings\Matt\Desktop\wndprogtest\wndprogtest\Debug\BuildLog.htm"
wndprogtest - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

##### Share on other sites
Ok, looks like your IDE isn't configured to locate the DirectX SDK installation.

This step varies a bit depending on which version of Visual Studio you're using.

1) Go to Tools menu -> Options....

On VS 2005:
2) Select Projects and Solutions -> VC++ Directories.

On VS 2003:
2) Select Projects -> VC++ Directories.

3) Then select "Library Files" from the top-right drop-down box, and add "C:\Program Files\Microsoft DirectX SDK (February 2007)\Lib\x86" to the list (but change the path to what your actual DX SDK install directory is).

[EDIT]Arg! You can probably ignore this post so far.

I gave you the wrong library name before! Sorry, that should be d3d9.lib (or d3d8.lib etc depending on which SDK version you have installed), not d3d.lib.

##### Share on other sites
Quote:
 Original post by Hodgman[EDIT]Arg! You can probably ignore this post so far.I gave you the wrong library name before! Sorry, that should be d3d9.lib (or d3d8.lib etc depending on which SDK version you have installed), not d3d.lib.
Actually, IID_IDirectDraw7 is in dxguid.lib, and you'll probably need ddraw.lib too.

Although, I'd highly recommend against using DirectDraw - it's not hardware accelerated, it's out of date, and it needs a lot of code to get stuff working. I'd recommend going for Direct3D instead.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 27
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634098
• Total Posts
3015525
×