Archived

This topic is now archived and is closed to further replies.

CoolMike

DirectX with C++

Recommended Posts

CoolMike    122
A few days ago I started rewriting all my "old" DirectX code from C into C++, with objects for DirectDraw, DirectInput, and DirectSound, along with objects for the rest of the game. It was going well until I compiled the CGraphics.cpp file, which gave me a LNK2001 error: "unresolved external symbol _IID_IDirectDraw7", which stems from the first line of my DirectDraw initialization routine: DirectDrawCreateEx(NULL, (VOID**)&lpdd, IID_IDirectDraw7, NULL); If I remove this line, the program compiles, but DirectDraw will obviously not work. I know this is just a problem with my new C++ code and having multiple *.cpp files. What should I do to get this to compile correctly? I can provide source for anyone that needs to see it, otherwise any pointers at all would be great.

Share this post


Link to post
Share on other sites
Midnight Coder    122
You must #include the proper files. You must do this for every source file. The best way is to have one header file #include all needed header files (like Windows.h, DDraw.h, etc.), and then #include that header file in every source file. When you start a new project, VC++ will give you an option which will let it create a stdafx.h file that can be used for this purpose.

Share this post


Link to post
Share on other sites
CoolMike    122
Midnight Coder, you are my new best friend. Just before I posted my message I thought I might have been missing a library reference, but I couldn''t think of the library file I was missing. All I did was add the dxguid.lib file to my project and no more error! Thanks!

Share this post


Link to post
Share on other sites
Bully    144
Although you may of solved your problems I''m going to move this to the DirectX form. Also people having similar problems may be able to get something out of this post.

Share this post


Link to post
Share on other sites