Jump to content
  • Advertisement
Sign in to follow this  
Akul

Help on Errors Please

This topic is 3918 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

I am trying to get some sample code from here running and having a problem to two, I have Dev-C++ (V. 4.9.9.2) and Microsoft DirectX SDK (November 2007). Below is a screen shot of how my directories are set up and my error, and the code follows. http://img219.imageshack.us/my.php?image=screenvm0.jpg
#include "dxguid.lib"
#include "ddraw.lib"
#include "ddraw.h"
#include <cstdlib>
#include <iostream>

using namespace std;

    // globals (ugh)
LPDIRECTDRAW lpDD; // DirectDraw object defined in DDRAW.H

/*
 * Function to initialize DirectDraw
 * Demonstrates:
 *   1) Creating the Direct Draw Object
 *   2) Setting the Cooperative level
 *   3) Setting the Display mode
 *
 */
bool DirectDrawInit(HWND hwnd)
{
    HRESULT ddrval;
    
   /*
    * Create the main DirectDraw object.
    *
    * This function takes care of initializing COM and Constructing
    * the DirectDraw object.
    */
    ddrval = DirectDrawCreate( NULL, &lpDD, NULL );
    if( ddrval != DD_OK )
    {
        return(false);
    }

   /*
    * The cooperative level determines how much control we have over the
    * screen. This must at least be either DDSCL_EXCLUSIVE or DDSCL_NORMAL
    *
    * DDSCL_EXCLUSIVE allows us to change video modes, and requires
    * the DDSCL_FULLSCREEN flag, which will cause the window to take over
    * the fullscreen. This is the preferred DirectDraw mode because it allows
    * us to have control of the whole screen without regard for GDI.
    *
    * DDSCL_NORMAL is used to allow the DirectDraw app to run windowed.
    */
    ddrval = lpDD->SetCooperativeLevel( hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
    if( ddrval != DD_OK )
    {
        lpDD->Release();
        return(false);
    }

   /*
    * Set the video mode to 640x480x8
    * This is allowed because we have set exclusive mode above
    */
    ddrval = lpDD->SetDisplayMode( 640, 480, 8);
    if( ddrval != DD_OK )
    {
        lpDD->Release();
        return(false);
    }

    return(true);
}

int main(int argc, char *argv[])
{    
    system("PAUSE");
    return EXIT_SUCCESS;
}

[Edited by - Akul on January 4, 2008 9:38:56 AM]

Share this post


Link to post
Share on other sites
Advertisement
I tried putting my code in <code> tags, but when I previewed it, they were treated as text (the tags), How am I should I post code here?

Share this post


Link to post
Share on other sites
Quote:
Original post by Akul
I tried putting my code in <code> tags, but when I previewed it, they were treated as text (the tags), How am I should I post code here?
Use [ source ] tags, or [ code ] for short snippets (<10 lines).

As for the actual problem, I didn't think Dev-C++ was supported by any recent DirectX SDK? Is there any reason you're not using the free version of Visual Studio 2008 (which is much better)?

I'm not a Dev-C++ person, but it looks like you don't have the main.cpp in your project, or you don't have the path to it in your project set up correctly.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Is there any reason you're not using the free version of Visual Studio 2008 (which is much better)?




Microsoft Visual C++ 2008 Express Edition?

Share this post


Link to post
Share on other sites
The DirectX SDK you have is probably compiled for the Microsoft C++ compiler. Dev-C++ uses the GCC compiler/linker tools, and will probably complain.
If this is the case, you will either have to download DirectX SDK for GCC (MingW), or get Microsoft's Visual C++ and use it with the SDK you already have installed.

Quote:

#include "dxguid.lib"
#include "ddraw.lib"

You are not supposed to include lib files in your source code, only h files.
Most IDE's will have a list somewhere in the menus where you can add the lib files your program depends on. I'm using Visual C++ 2008 express myself, so I don't remember where in the Dev-C++ menus to do it.

Some info here How to link, even though I also recommend downloading the Visual C++ 2008 express if you have a decent bandwidth.

Share this post


Link to post
Share on other sites
Tried that Pulpfist and got further.

" [Linker error] undefined reference to `DirectDrawCreate@12' "

and I am downloading C++ Express 2008.

Share this post


Link to post
Share on other sites
Sounds good. The undefined reference linker errors is a classic and usually means that you forgot to add a cpp file to your project or that you forgot to add a lib file to the list of dependencies.

Feel free to ask once you got visual c++ up and running...

Share this post


Link to post
Share on other sites
Quote:
Original post by pulpfist
Feel free to ask once you got visual c++ up and running...


Lol... Yeah. Can you direct me to a decent tutorial in basic game development with the Microsoft Visual C++ 2008? Or should it be very similar?

Also, similar error from Microsoft Visual C++ 2008:

1>TestProject1.obj : error LNK2019: unresolved external symbol _DirectDrawCreate@12 referenced in function "bool __cdecl DirectDrawInit(struct HWND__ *)" (?DirectDrawInit@@YA_NPAUHWND__@@@Z)
1>H:\My Documents\Visual Studio 2008\Projects\TestProject1\Debug\TestProject1.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://h:\My Documents\Visual Studio 2008\Projects\TestProject1\TestProject1\Debug\BuildLog.htm"

Share this post


Link to post
Share on other sites
Well that depends heavily on what kind of game you want to create and what level you are at of course.
If you want to do 3D graphics, you can use a graphic engine like Ogre or DarkGDK.
If you want to start out with some 2D stuff you should give LazyFoos tutorial a try.

However, if you are new to game development you might want to get used to the basics first doing some simple DirectX tutorials. Here is a decent tutorial. This one doesn't require any third party libraries except DirectX SDK.

The resources pages here on GD will give you more.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!