compiling directx 9 problems

Started by
19 comments, last by Mattijs2 15 years, 5 months ago
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
http://digitalart.f-sw.com
Advertisement

Not sure about this but just because I linked it maybe the compiler does not know where to look for it.

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
http://digitalart.f-sw.com
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
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
http://digitalart.f-sw.com
Quote:Original post by 3dmodeler
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
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:
Include files

And lib files:
Library files
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]
(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.
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)
http://digitalart.f-sw.com
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.
Quote:Original post by 3dmodeler
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)
$(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 Mattijs2
I 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.

This topic is closed to new replies.

Advertisement