# Setting up Direct3D - Won't compile

## Recommended Posts

This is about DirectX but I figured it belonged here since it's such a basic problem I'm having. I've just begun looking at DirectX and I downloaded a demo that draws a triangle with Direct3D from here http://www.ultimategameprogramming.com/demoDownload.php?category=DirectX&page=1 I opened it in Dev-C++ and linked it to d3d9.lib. When I compile & run with the D3DINTRO folder on the desktop I get this error: " C:\Dev-Cpp\Makefile.win [Build Error] ["../Documents and Settings/USERNAME/Desktop/D3DIntro/D3DIntro.o"] Error 1 " Then I figured I'd put it in the Dev-Cpp folder and it gives me this: "12 C:\Dev-Cpp\D3dTriangle\main.cpp d3dx9.h: No such file or directory. " Here it appears to have no problem finding d3d9.h but can't find d3dx9.h which is in the same folder. I have the June version of the DirectX SDK and it's in the default folder. As a complete noob to these things I'm totally lost and can't figure out where I went wrong o_O. I even tried it in MS Visual C++ but it still doesn't compile. So what's wrong and why does it give different errors based on where the folder is placed when neither locations have the header files loose or anything? I've been looking around and I can't find anything that might help... I'm sure it's something fairly simple but I've no clue about DirectX at this stage :D

##### Share on other sites
jpetrie    13099
Quote:
 I even tried it in MS Visual C++ but it still doesn't compile.

Keep using MSVC++; the official DX SDKs don't work well with Dev-C++. Vanilla Dev-C++ is a really poor IDE nowadays.

When you attempt to compile with MSVC++, what errors do you get? If they're similiar -- D3D headers not being found -- make sure you are including them properly (use the #include <d3d9.h> syntax, not #include "d3d9.h") and make sure the paths to the DX SDK install are set up properly (there are paths for binaries, headers, and libraries that need to be set up, although the binaries path is less important). You do this in Tools -> Options -> Project Directories (or something like that).

##### Share on other sites
K, so I went to the VC++ Directories menu which had directories for Includes, Executables, References, Libraries, Sources, Exclude Directories.

The Include bit has 3 lines starting with "$(VCInstallDir)include" so I added the path to the includes in the DirectX SDK after those lines. Was that right? Did the same for the libraries and now it gives me: "1>c:\program files\microsoft directx sdk (june 2007)\include\d3d9.h(40) : fatal error C1083: Cannot open include file: 'objbase.h': No such file or directory" Where objbase.h is an include in the d3d9.h file itself... which is nowhere to be found in the SDK. Looks like it can at least find d3d9.h now though, doesn't it? #### Share this post ##### Link to post ##### Share on other sites jpetrie 13099 Quote:  The Include bit has 3 lines starting with "$(VCInstallDir)include" so I added the path to the includes in the DirectX SDK after those lines. Was that right?

That sounds almost right -- just to be sure each entry should be a bit more specific, for example, the entry under the "Libraries" list should point to "Path/To/DirectXSDK/Lib" and and the one for "Includes" should be "Path/To/DirectXSDK/Include"

There might be capitalization issues, and one of them (I forget which) has a subdirectory (perhaps for 64/32 bit?) that you should add, I think.

objbase.h is part of the Platform SDK, I think. Have you installed that and followed the instructions for configuring it with VS?

##### Share on other sites
Quote:
 objbase.h is part of the Platform SDK, I think. Have you installed that and followed the instructions for configuring it with VS?

I hadn't, no. But I have that done now ;)

I followed this: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

The app in Step 5 works fine but it says it's out of date before it runs. Is that strange? It says it's out of date but the app was created by VC++ itself :o

It says D3DINTRO is out of date and then when I try to run it I get

1>Compiling...
1>D3DIntro.cpp
1>D3DIntro.obj : error LNK2028: unresolved token (0A000062) "extern "C" struct IDirect3D9 * __stdcall Direct3DCreate9(unsigned int)" (?Direct3DCreate9@@$$J14YGPAUIDirect3D9@@I@Z) referenced in function "bool __cdecl InitializeDirect3D(struct HWND__ *)" (?InitializeDirect3D@@$$FYA_NPAUHWND__@@@Z)
1>D3DIntro.obj : error LNK2019: unresolved external symbol "extern "C" struct IDirect3D9 * __stdcall Direct3DCreate9(unsigned int)" (?Direct3DCreate9@@$$J14YGPAUIDirect3D9@@I@Z) referenced in function "bool __cdecl InitializeDirect3D(struct HWND__ *)" (?InitializeDirect3D@@$$FYA_NPAUHWND__@@@Z)
1>C:\Documents and Settings\Seán\Desktop\D3DIntro\Debug\D3DIntroNET.exe : fatal error LNK1120: 2 unresolved externals

I've got the DirectX SDK, it seems it can find all the header files and the libraries now, I've got the Platform SDK and I followed the configuration guide... what else could it be?

##### Share on other sites
jpetrie    13099
The "out of date" messages probably mean the project is out of date (needs to be rebuilt before you run it). That's all.

Sounds like you're not actually linking to the D3D libraries now. In the Project Settings, under Linker someplace, there is a line for additional inputs. Make sure d3d9.lib, d3d9xlib, et cetera are there (you use spaces to separate them in the input line).

You can also use #pragma comment(lib,"d3d9.lib") et cetera.

##### Share on other sites
Quote:
 Original post by jpetrieSounds like you're not actually linking to the D3D libraries now. In the Project Settings, under Linker someplace, there is a line for additional inputs. Make sure d3d9.lib, d3d9xlib, et cetera are there (you use spaces to separate them in the input line).

Nope... I have

d3d9.lib
d3dx9.lib
d3dx9d.lib

and

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib

in the inherited values box below :/

Anyone?