# compiling directx 9 problems

## Recommended Posts

I am a complete beginner to directx and just got a new compiler( my first ever) Visual c++ express edition. I asked my question on the msdn forums but they sometimes don't answer so i was hoping someone here would know. I ahve a a directx 9.0 book in it there are lots of examples to compile. The book was made for two specfic compilers visualc++ 6.0 or visual c++.net I am not using either so it is confusing since there are certain files you have to include depending on what compiler you use. In one example called Dolphin I include the main.cpp the resource.h and winmain.rc I get an error that says can't find D3DX9.h when i add that i still get the same error What i am asking is what exactly are the files i have to add? I know it sounds dumb but i must be missing something. Also according to the readme file there are two .vsh files but those files are in another directory, who knows why. do i add those? Hopefully this will make sense to someone 3dmodeler

##### Share on other sites
Have you downloaded the latest DirectX SDK? If not try that you can get it here: DirectX August 2008 SDK

##### Share on other sites
Yeah, make sure you ahve the latest DirectX SDK installed, also make sure you have the include file looking exactly like this:
#include <d3d9.h>
#include <d3dx9.h>

and in the project properties under Config Properties>Linker>Input
you have:
d3d9.lib
d3dx9.lib

making sure each .lib file is seperated by a space.

Hope that helps,
Progames25

##### Share on other sites
I think that visual c++ comes with the latest Direct x SDK That's why i am so confused The compiler i installed was just a few weeks ago. What about those .vsh files aren't they supposed to be included, if so where do i put them header, source folders, where exactly?

3dmodeler

##### Share on other sites
Quote:
 Original post by 3dmodelerI am a complete beginner to directx and just got a new compiler( my first ever)Visual c++ express edition. I asked my question on the msdn forums but they sometimes don't answer so i was hoping someone here would know. I ahve a a directx 9.0 book in it there are lots of examples to compile. The book was made for two specfic compilers visualc++ 6.0 or visual c++.net I am not using either so it is confusing since there are certain files you have to include depending on what compiler you use. In one example called Dolphin I include the main.cpp the resource.h and winmain.rc I get an error that says can't find D3DX9.h when i add that i still get the same error What i am asking is what exactly are the files i have to add? I know it sounds dumb but i must be missing something. Also according to the readme file there are two .vsh files but those files are in another directory, who knows why. do i add those? Hopefully this will make sense to someone

Quote:
 Original post by 3dmodelerI think that visual c++ comes with the latest Direct x SDK That's why i am so confused The compiler i installed was just a few weeks ago. What about those .vsh files aren't they supposed to be included, if so where do i put them header, source folders, where exactly?
Visual C++ .NET is almost identical to Visual Studio 2008 (Which is presumably what you have).

The DirectX SDK does not come with Visual Studio - that'd be an unnecessary addition for a lot of people, so you need to download it seperately to compile DirectX code.
Having said that, if the book has a version of the DirectX SDK on the CD, I'd install that (for now), since the SDK has changed a lot recently and newer SDKs probably won't work without a bit of tinkering.

VSH are Vertex SHader files. You don't include them in any way when building the code, they're data files.
The book should probably have a project workspace (A .sln file, or possibly .dsw for VS6) - you should open (And convert if it prompts you) that, since that'll have all the source files added to the project and should be ready to compile once you've installed all the necessary SDKs.

##### Share on other sites
A few more questions first off what is the winmain.rc file anddo i include that and where? I installed Direct SDK 9.0 a ferw years ago. If I download the latest Directx SDK 10 I heard that it either won't compile in my xp pro system or that if it does compile won't be able to run the program Am misunderstanding something?

3dmodeler

##### Share on other sites
Well, there isn't really a 'directx 10 sdk'. There's the August 2008 DirectX SDK. This SDK should include everything you need for working with either directx 9 or directx 10.

Each SDK will mention all changes from the previous version. If you look at the June 2008 SDK it says it has removed DirectX 8 related items and managed directX related items without mentioning removing DirectX 9 functionality. The Auguest 2008 SDK doesn't mention removing anything at all, much less DirectX 9.

If it takes MS the same amount of time to get rid of DirectX 9 as it took to get rid of DirectX 8 it'll be another 2-4 years before they remove it from the SDK. And even then you can always download earlier versions of the SDK>

Clicky.

##### Share on other sites
Quote:
 Original post by 3dmodelerA few more questions first off what is the winmain.rc file anddo i include that and where? I installed Direct SDK 9.0 a ferw years ago. If I download the latest Directx SDK 10 I heard that it either won't compile in my xp pro system or that if it does compile won't be able to run the program Am misunderstanding something?3dmodeler
You can't run D3D10 apps on XP, you need Vista. You'll be able to compile D3D10 apps, but it's a bit pointless unless you have a Vista machine to run on. D3D10 requires a totally different driver model, and trying to get it to run on XP is like getting D3D9 to run on Linux - there's projects out there trying to do it, but it's pretty flakey, not really practical, and not officially supported.

winmain.rc is a resource file. If you add it to your project, then Visual Studio will compile the resources into your EXE file. Again, if this is code from a book it should have a project file already, and the resource file will already be added.

##### Share on other sites
Quote:
 Original post by Progames25Yeah, make sure you ahve the latest DirectX SDK installed, also make sure you have the include file looking exactly like this:#include #include and in the project properties under Config Properties>Linker>Inputyou have:d3d9.libd3dx9.libmaking sure each .lib file is seperated by a space. Hope that helps,Progames25

Under Config Properties>Linker>Input I don't have anything. How do i link to them? I am using visual c++ express edition 2008

3dmodeler

##### Share on other sites
Quote:
 Original post by 3dmodelerUnder Config Properties>Linker>Input I don't have anything. How do i link to them? I am using visual c++ express edition 20083dmodeler
You put "d3d9.lib; d3dx9.lib" (no quotes) in the "Additional Dependencies" field.

##### Share on other sites
Did that but still get this message. Anything else i can try?

fatal error C1083: Cannot open include file: 'D3DX9.h': No such file or directory

3dmodeler

##### Share on other sites

If i go to Tools + Options, Projects and Solutions, VC++ Directories. Add the paths to my DirectX SDK installation folders and any include fils as well
that should do it. problem is you can't just browse to the file, the closest i can get to is the folder. I have to type it but it look like the one below

$VCInstallDir)atlmfc\lib Hoping someone here can walk me through 3dmodeler #### Share this post ##### Link to post ##### Share on other sites I might be mistaken and you might already have it in there, but that seems like it can't find the header files themselves, or in other words it's not a linker problem, but it can't compile. You need to add the directories of DirectX to your Directories. Seems like what you were gonna try to do, but if it's giving you the error I'm assuming you either haven't tried it yet or added the wrong folder. Make sure to add the lib, bin, and include directories of the latest installation of DirectX SDK to your VC++ Directories, each of those folders needs to go under the correct "category" in the drop-down list when you're adding them, and add them to the top of the list so that it looks in those folders first. You're gonna need to add the full path of the directories unless you have a system variable setup that you could use, but full paths are a safer bet. The only problem you'd ever run into with full paths is if you ever reinstall the SDK, you'll need to change the path to point to the new SDK. Also, make sure you're putting in the path to the SDK, not the Runtime environment. Hope this helps. -Alex #### Share this post ##### Link to post ##### Share on other sites It is confusing as hell for me. I have never had so much trouble with any program before. I have my lib files are here. C:\DXSDK\lib so i go into directories and usingthe browse button i click on it to get that, but all of the other files i see there are written like this$VCInstallDir)atlmfc\lib odd looking writing
I add c:\DXSDK/lib and it still does not work so i am doing it wrong. Any ideas?
The help files don't help me very much. How are you direct x files set up?

3dmodeler

Quote:
 Original post by 3dmodelerIt is confusing as hell for me. I have never had so much trouble with any program before. I have my lib files are here. C:\DXSDK\lib so i go into directoriesand usingthe browse button i click on it to get that, but all of the other files i see there are written like this $VCInstallDir)atlmfc\lib odd looking writingI add c:\DXSDK/lib and it still does not work so i am doing it wrong. Any ideas?The help files don't help me very much. How are you direct x files set up? 3dmodeler First, that looks like the temp. directory that the installer extracts to, are you sure that's the directory the SDK is actually installed to? Second, the lib directory has a x86 and x64 subdirectory for the libraries. If you're making 32-bit apps, you'll want to set that to the x86 subdirectory. From my setup - Library files: And lib files: #### Share this post ##### Link to post ##### Share on other sites Since this is a beginner's forum, let's take it from the top: Basically, there are two stages in creating a program: 1) compiling your source files and 2) linking the compiled source files together to create an executable. Besides your own source code, you will always use already compiled code built by somebody else. Most of this precompiled code comes as a header and a library file. You use the header when compiling your code, and the library when linking your code. If the header is in the same folder as the source file, the compiler will automatically find the header file, and everything compiles. If the header is in another folder, you must tell the compiler where it can find the header. In the case of a Directx header file you need (e.g. d3d9.h), you can write #include "C:\\SDKs\\DirectX SDK August 2007\\Include\\d3d9.h" (In my case, the header files of the Directx SDK are in folder 'C:\SDKs\DirectX SDK August 2007\Include'.) However, this is not very flexible. If, at some point in time, you install the new SDK in 'c:\SDKS\DXSDK Oktober 2008', you have to change all the include paths in your code. Also, if you give the code to somebody else, they will probably not have the SDK installed in the same folder. Fortunately, instead you can write #include <d3d9.h> Using '<' and '>' instead if double quotes will tell the compiler to look for the header file in its 'special' include folders/paths instead of just the same folder as the source file to be compiled (when the compiler is installed, some paths are automatically set. That's why you can just type #include <stdio.h> and the compiler will find it). You will have to add the path to the Directx files yourself. Evil Steve shows this in his first image (although it says 'From my setup - Library files'). He has added the folder where his Directx header files are found to the top of the list of 'include directories'. When the compiler searches for an include file, it will try each of the folders in turn, starting at the top, until it has found the file. (Continue?) [Edited by - Mattijs2 on October 26, 2008 2:52:38 PM] #### Share this post ##### Link to post ##### Share on other sites (continued) If the compiler can find all the header files from all the different folders (e.g. windows.h from the platform include folder, d3d9.h from the Directx include folder, and TurboPong.h from the current folder, it will successfully compile TurboPong.cpp Now you have to link everything together. For this, the linker needs a number of library files that contain compiled code for the functions you used from the header files. Most of the time, the names for header and library are the same. Like the include folders, you have to tell the linker which libraries are needed, and where they are. The easiest way is to write in TurboPong.cpp: #pragma comment (lib, "C:\\SDKs\\DirectX SDK August 2007\\Lib\\x86\\d3d9.lib") but again, this is not very flexible. Better is to write #pragma comment (lib, "d3d9.lib") and add the folder where this file can be found to the 'Library files' list of paths (the second image from Evil Steve). Notice that the double quotes are not changed to '<' and '>' for library files. Before I get kicked from this forum, what _normal_ people do is add the library to the list of libraries in the Project Property Pages->Configuration Properties->Linker->Input page. A number of libraries are already filled in. Just add d3d9.lib to the list. The linker will use its library paths to search for each of the library files. Note that you could also add "C:\SDKs\DirectX SDK August 2007\Lib\x86\DxErr9.lib" (including the double quotes) to the list if you don't want to add the path to the list of library paths. #### Share this post ##### Link to post ##### Share on other sites Mattijs2, thanks problem i was not sure if i was adding it correctly. Evilsteve's pic showed i was. Now a new problem ( what else is new) I am getting errors some are syntax errors but i did not write the code, it should work correctly Check it out Compiling... dolphin.cpp c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C2146: syntax error : missing ';' before identifier 'PVOID64' c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C2146: syntax error : missing ';' before identifier 'Buffer' c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\documents and settings\roccomarcantonio\start menu\my documents\visual studio 2008\projects\dolphins\dolphins\dolphin.cpp(15) : fatal error C1083: Cannot open include file: 'DXUtil.h': No such file or directory Project : warning PRJ0018 : The following environment variables were not found:$(VCDXSDK\Lib;$(VCInstallDir) 3dmodeler Build log was saved at "file://c:\Documents and Settings\RoccoMarcantonio\Start Menu\My Documents\Visual Studio 2008\Projects\Dolphins\Dolphins\Debug\BuildLog.htm" Dolphins - 6 error(s), 0 warning(s) #### Share this post ##### Link to post ##### Share on other sites I had the same problem. I did the most horrible thing imaginable: I just changed winnt.h to //typedef void * POINTER_64 PVOID64;typedef void * PVOID64; (I put the original typedef in comments, and added my own). Since I am on a 32 bit Windows XP version, I don't need the 64 bit stuff anyway. If somebody has a better way of solving this, please come forward. #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by 3dmodelerMattijs2, thanks problem i was not sure if i was adding it correctly.Evilsteve's pic showed i was. Now a new problem ( what else is new) I am getting errors some are syntax errors but i did not write the code, it should work correctly Check it outCompiling...dolphin.cppc:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C2146: syntax error : missing ';' before identifier 'PVOID64'c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-intc:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C2146: syntax error : missing ';' before identifier 'Buffer'c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-intc:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-intc:\documents and settings\roccomarcantonio\start menu\my documents\visual studio 2008\projects\dolphins\dolphins\dolphin.cpp(15) : fatal error C1083: Cannot open include file: 'DXUtil.h': No such file or directoryProject : warning PRJ0018 : The following environment variables were not found:$(VCDXSDK\Lib;$(VCInstallDir)3dmodelerBuild log was saved at "file://c:\Documents and Settings\RoccoMarcantonio\Start Menu\My Documents\Visual Studio 2008\Projects\Dolphins\Dolphins\Debug\BuildLog.htm"Dolphins - 6 error(s), 0 warning(s)$(VCDXSDK\Lib;\$(VCInstallDir) is not a valid path, you're missing a bracket, and you probably shouldn't have two paths in one entry in your VC Directories. That may or may not fix the first problem.

Quote:
 Original post by Mattijs2I had the same problem. I did the most horrible thing imaginable: I just changed winnt.h to*** Source Snippet Removed ***(I put the original typedef in comments, and added my own).Since I am on a 32 bit Windows XP version, I don't need the 64 bit stuff anyway. If somebody has a better way of solving this, please come forward.
Changing headers like that is a really bad idea - you've just stopped your code compiling on any other machine except your own, and if you ever need to reinstall Visual Studio, you'll have to make those changes again.

Unfortunately, I don't recall what causes those errors offhand, perhaps including headers in a funny order. Someone else may know.

##### Share on other sites
Quote:
 Changing headers like that is a really bad idea - you've just stopped your code compiling on any other machine except your own, and if you ever need to reinstall Visual Studio, you'll have to make those changes again.

Funny enough, this is not true. I have the same Visual Studio on my laptop with 32 bit Vista, and everything compiles fine without the changes to winnt.h. I had the same problem at work though and ended up changing the header file.

So it must be something that has to do with the Visual Studio installation. My code will compile fine on other machines (well, at least one other machine). So I am also not sure I have to make the change again when I install Visual Studio again.

I agree it is a really bad idea, but after searching for the solution for hours, one has to do something. After all, I had a simulator to build (see www.gpsim.eu)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627694
• Total Posts
2978672

• 19
• 14
• 12
• 10
• 12