Archived

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

DirectX with C++

This topic is 5979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
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