# Syntax error, problem with directx sdk & visual studio

## Recommended Posts

I don't seem to be understanding some problems here. I'm new to C++ and it's way of including libraries and such, and I'm having a problem I would love to get support for. I can't find help anywhere on microsoft, or anywhere else. I found this site, and must say it's a wounderful resource. Now, onto the topic. I've gone to project -> settings -> links and added in dxguid.lib and ddraw.lib, and made my #include for <ddraw.h>. Even when I take an example source and try to run it, I keep getting this same error. I have the DirectX SDK installed, the one from October 2004 I believe. I keep getting an error on LPDIRECTDRAW7 lpDD = NULL; saying LPDIRECTDRAW7 is an invalid reference, and it doesnt seem to be including any directx variable types, or anything. I'm not sure what the problem is, exactly. Sorry I couldn't be more specific, but if this isn't an easy-fix and someone doesn't come along real quick and knock the stupidity out of my head, I'll go more indepth and post more specific details about this. Thanks! [Edited by - MLane on November 14, 2004 8:46:15 PM]

##### Share on other sites
Try this:
#include <ddraw.h>#pragma comment(lib,"ddraw.lib")#pragma comment(lib,"dxguid.lib")

##### Share on other sites
i think the problem is you haven't pointed your project toward the location of the headers and libraries, As well as saying what header you want to include and what libraries to link to you have to say where they are. Go into project settings then:

1) in C/C++ folder, in General, there is an entry "Additional Include Directories". Add the include folder of your directx sdk install there.

2) Under the Linker folder in General, there is an entry "Addition Library Directories". Add the lib folder of your directx sdk install there.

Hopefully this should sort all your problems out.

##### Share on other sites
I can't seem to find any of the tabs you're talking about. Are you using visual studio 6, or .NET? I'm using 6.

I just reinstalled my DirectX SDK, but it doesn't really give me a folder for it. I have the files I extracted from the autoextracting exe that I downloaded, and I still have them in a /DirectX SDK/ folder in my visual studio folder. The pragma code didn't help, but thanks for the try.

Maybe you could provide some screenshots of the area you're referring to, just for simple term understanding? Some of these aspects of the designer are a bit vague, and that would really help. Also, here are the exact specific errors:

error C2146: syntax error : missing ';' before identifier 'lpDD7'

error C2501: 'LPDIRECTDRAW7' : missing storage-class or type specifiers

fatal error C1004: unexpected end of file found

Thanks again for all your help! I'm beginning to owe these forums!

[Edited by - MLane on November 14, 2004 8:43:13 PM]

##### Share on other sites
You must make sure the ddraw.h is included in every .cpp file in your project, and before you start using LPDIRECTDRAW.

##### Share on other sites
In case this is your problem, in VC6, the include and library directories are set in Tools -> Options -> Directories. They must be set on top of the lists since you want them to replace the DirectX version that comes with VC6 (DX5 I think).

##### Share on other sites
I can't seem to find the directory where my ddraw lib is. I'm running a search for it now, and the confusing aspect about this, I think, is that this directx SDK didn't create itself a specific folder containing it's content. I believe random DLL's were just stuck in my system32 folder and around my video studio folders which are already included into my project. Any other suggestions? Anyone else you know who has had this problem and how they've fixed it? Or, what may help, is there someone who has successfully been able to run directx through visual studio and give me a step-by-step on how they include their libraries?

##### Share on other sites
MLane, as far as I know, DirectX SDK installation program does everything for you already if you have Visual Studio or Visual C++ installed. You don't need to set your directory settings. It does that to you already. In case it missed it, the library files should be in where you install the SDK. Just search through the subfolders, and you will find a bunch of .lib files.

The problem you pointed is usually an #include problem, using symbols before they are defined, forgetting to #include a header file. Use the #pragma I told you before to link to a library instead of going through project properties. Include ddraw.h in every .cpp files you have, not just in one file.

If you do not have the directory setup correctly, your program won't compile because it can't find the file you specified. It will say something like "cannot include file ddraw.h" or "cannot link file ddraw.lib" Your error is not because ddraw.h or ddraw.lib is not there but because you forget to include them in one of your files, you organize your files wrong. If you have put the #include and #pragma like I told you before, and you don't see that message, that means your directory settings is OK, you don't need to mess with them.

##### Share on other sites
Well after a mixture of various things, I seem to have gotten my compiler at school to run without any errors. Not sure if it'll work just yet, and I'm going to try it here at home now.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628328
• Total Posts
2982099

• 22
• 9
• 9
• 13
• 11