Skip to main content
GameDev.net gamedev.net
🔒 Locked

Error in using DirectDraw with VC++

Started by sTurtle Feb 27, 2000 at 8:39 AM 10 replies 950+ views
Original Post
sTurtle
sTurtle
Dear all: Here had a part of the code: LPDIRECTDRAW lpdd =NULL; // standard DirectDraw 1.0 LPDIRECTDRAW lpdd4 =NULL; // DirectDraw 6.0 interface DirectDrawCreate(NULL,&lpdd,NULL); lpdd->QueryInterface(IID_IDirectDraw4,(LPVOID *)&lpdd4); it had error when I run it : ABC.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4 Debug/ABC.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. ABC.exe - 2 error(s), 0 warning(s) How can I do ? Turtle Turtle Turtle
Turtle Turtle Turtle
Spellbound
Spellbound
This is an extremely common question on this board.

The answer is always: You must link with dxguid.lib.
Zombie
Zombie
Uh... how? I''m not using C++, I use VB, but I want to know that anyway. I went to Tools menu, there options and then Directories. I added DirectX SDK/include path there, but I still have errors.


Linking...
WinMain.obj : error LNK2001: unresolved external symbol "public: void __thiscall DXEngine::SetClientParams(int,int)" (?SetClientParams@DXEngine@@QAEXHH@Z)
WinMain.obj : error LNK2001: unresolved external symbol "public: __thiscall CEngine::CEngine(struct HWND__ *,struct HINSTANCE__ *,int,int,int,int)" (??0CEngine@@QAE@PAUHWND__@@PAUHINSTANCE__@@HHHH@Z)
WinMain.obj : error LNK2001: unresolved external symbol "public: __thiscall CEngine::~CEngine(void)" (??1CEngine@@QAE@XZ)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/WinMain.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

WinMain.exe - 5 error(s), 0 warning(s)
jwalker
jwalker
You must add dxguid.lib and ddraw.lib to your link in the project settings. Make sure the directory settings in your VC++ contains both the #include and the Lib directory paths of your DirectX SDK. Make sure both the #include and Lib paths are the paths on top. Not the bottom of the list of directory paths in your VC++

todderod
todderod
I am not sure about the need to link the.lib file.
For C++, ading the line
#define INITGUID
works well for me. If there is some other gains by adding the lib, may you tell me please?

For VB, I don''tknow how to do it. Sorry! (I am learning how to do DX in VB though so Imightsoon be able to answer)
Zombie
Zombie
I don''t need an answer to "how to do that in VB". It''s in Project/References and then select DirectX7 for Visual Basic Type Library . I just said that I use VB but I want to know how C++ works.
mbarela
mbarela
If on an off change the above posts dont work for you make sure that you have added the direct x 7 lib and include files to visual c++ by going to tools->options->directories and adding your mssdk\include and mssdk lib directories and then dragging them to the top of the list. MSVC trys to use direct x 3 by default and thats why you cant query a new interface. You should also do all the stuff the other respondants said. Direct Draw is pretty easy to use once you have it all set up properly. Good Luck. =)

Mike Barela
mbarela@earthlink.net
Mike BarelaMikeB@yaya.com
null_pointer
null_pointer
Zombie: Those error messages probably mean that you either forgot to add the .cpp file(s)
for that code to your project, or you forgot to code those two functions in the .cpp file(s).

If the compiler can find the function/class declared in the .h file but not defined in
the .cpp file, it tells you that there's an undefined external symbol. That's just
compiler-speak for "Help! I can't find the code for this thing!"

(technically, it's the linker, but that adds some complexity to the discussion)

Good Luck!


- null_pointer



Edited by - null_pointer on 3/1/00 7:46:48 AM
Armitage
Armitage
And also, it''s not
LPDIRECTDRAW lpdd4 =NULL; // DirectDraw 6.0 interface
but
LPDIRECTDRAW4 lpdd4 =NULL; // DirectDraw 6.0 interface

I assume it''s from LaMothe

But otherwise, linking in ddraw.lib and defining INITGUID etc should be the problem.

A polar bear is a rectangular bear after a coordinate transform.
A polar bear is a rectangular bear after a coordinate transform.
sTurtle
sTurtle
I have another now...
when I run this code :
lpdd4->SetDisplayMode(640,480,8,0,0);

VC++ took error :
''SetDisplayMode'' : function does not take 5 parameters

but I saw the book and MSDN ... it really take 5 parameters
Here is wrong ?

Turtle Turtle Turtle
Turtle Turtle Turtle
Geradian
Geradian
Try using this code instead:


lpdd4->SetDisplayMode(640,480,8,0,0);
RoTTer
RoTTer
Hello Turtle!

I had the EXACt same problem (BOTH!) you are having now about 2 weeks ago.
The Lamothe''s book is wrong in some part when it says :
LPDIRECTDRAW lpdd4;

but it should say
LPDIRECTDRAW4 lpdd4; (look the 4 in first part)

As Armitage said. If you dont put the 4 it will just use the SetDisplayMode of the old DX 1.0 libs, and that one takes only 3 params. While the newer one (when you use LPDIRECTDRAW4) takes 5 params. And yes, I had forgotten to add the dxguid.lib to my project also.
Those 2 things made my program work in that part (but now Im stuck again in a different step. I hope this time isn''t for Lamothe''s book fault, or Ill return the damn book! j/k, of course, the book is very good in my opinion).

I hope this helps you.

Cya,
-RoTTer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.