getting SDL to work with Dev-Cpp

This is a discussion on getting SDL to work with Dev-Cpp within the Game Programming forums, part of the General Programming Boards category; I just posted a thread about a libiberty.h file but nobody responded to it throughout the whole day, and only ...

  1. #1
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198

    getting SDL to work with Dev-Cpp

    I just posted a thread about a libiberty.h file but nobody responded to it throughout the whole day, and only about 20 people looked at it... maybe this will draw more attention or more help.
    how do you get SDL to work with Dev-Cpp? first of all, there are NO good tutorials on how to make it work with Dev. there's tutorials for visual studio, but I am using Dev. not visual studio. I've even downloaded the devpack from the dev updater. it installed but when i start a new SDL project and try to compile the default set of code, it can't find the libiberty.h file. I can't find the file on my hard drive as it is not there, and I can't even find information about it because googling libiberty.h is futile.
    ANYONE? please and thank you
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Are you linking with the SDL libraries? (-lSDL, and maybe -lSDLmain)

    As for libiberty.h... I don't know, and as far as I can tell, I don't have the header either. I have libiberty.a, it seems to have come by default with MinGW. I've done projects with SDL before, but I've never liked with -liberty, only with the SDL libs.

    Perhaps some examples of the error's you're receiving / the test code you're using will help?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    In Project Options (Alt-P in Dev-C++ 4.0), you need to add a few libraries. I can't remember what they are, but it's like SDL.a and SDLlib.a or something. You also need to put SDL.dll in \windows\system (on my computer) or maybe \windows\system32.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    actually, I finally got SDL working. the example code they start you off with doesn't work right off the bat, because of that libiberty.h file (and they say
    Code:
    #include "SDL.h"
    but it should be
    Code:
    #include <SDL\SDL.h>
    I think libiberty.h MAY have something to do with using visual studio. but anyway I just started messing around with some beginner tutorials and started off by only including SDL.h. everything is working just dandy now, and i guess libiberty.h isn't necessary. AND i got this example code to work, but I had to take out the libiberty.h file obviously, and all the error checking... lol. pretty interesting

    and if you want the example code I was trying:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include <string.h>
    #include <libiberty.h>
    #include "SDL.h"
    
    /* The screen surface */
    SDL_Surface *screen = NULL;
    /* This function draws to the screen; replace this with your own code! */
    static void
    draw ()
    {
        static int direction = 0;
        static int value = 0;
        static int which = 0;
        SDL_Rect rect;
        Uint32 color;
    /* Create a black background */
        color = SDL_MapRGB (screen->format, 0, 0, 0);
        SDL_FillRect (screen, NULL, color);
    /* Determine which color the layer should have */
        if (direction == 0)
        {
            value += 2;
            if (value >= 256)
            {
                value = 255;
                direction = 1;
            }
        }
        else
        {
            value -= 2;
            if (value <= 5)
            {
                value = 0;
                direction = 0;
                which++;
                if (which == 5)
                    which = 0;
            }
        }
    /* Draw a layer with variable color */
        switch (which)
        {
          case 0:
              color = SDL_MapRGB (screen->format, value, 0, 0);
              break;
          case 1:
              color = SDL_MapRGB (screen->format, 0, value, 0);
              break;
          case 2:
              color = SDL_MapRGB (screen->format, 0, 0, value);
              break;
          case 3:
              color = SDL_MapRGB (screen->format, value, value, value);
              break;
          case 4:
              color = SDL_MapRGB (screen->format, value, 0, value);
              break;
        }
        rect.w = screen->w / 2;
        rect.h = screen->h / 2;
        rect.x = (screen->w / 2) - (rect.w / 2);
        rect.y = (screen->h / 2) - (rect.h / 2);
        SDL_FillRect (screen, &rect, color);
    /* Make sure everything is displayed on screen */
        SDL_Flip (screen);
    /* Don't run too fast */
        SDL_Delay (1);
    }
    
    int main (int argc, char *argv[])
    {
        char *msg;
        int done;
    /* Initialize SDL */
        if (SDL_Init (SDL_INIT_VIDEO) < 0)
        {
            asprintf (&msg, "Couldn't initialize SDL: %s\n", SDL_GetError ());
            MessageBox (0, msg, "Error", MB_ICONHAND);
            free (msg);
            exit (1);
        }
        atexit (SDL_Quit);
    /* Set 640x480 16-bits video mode */
        screen = SDL_SetVideoMode (640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);
        if (screen == NULL)
        {
            asprintf (&msg, "Couldn't set 640x480x16 video mode: %s\n",
              SDL_GetError ());
            MessageBox (0, msg, "Error", MB_ICONHAND);
            free (msg);
            exit (2);
        }
        SDL_WM_SetCaption ("SDL MultiMedia Application", NULL);
        done = 0;
        while (!done)
        {
            SDL_Event event;
    
            /* Check for events */
            while (SDL_PollEvent (&event))
            {
                switch (event.type)
                {
                case SDL_KEYDOWN:
                    break;
                case SDL_QUIT:
                    done = 1;
                    break;
                default:
                    break;
                }
            }
        /* Draw to screen */
            draw ();
        }
        return 0;
    }
    anyway, thanks everyone!
    Last edited by linucksrox; 10-23-2005 at 02:12 PM.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    Good luck with that. SDL is lots of fun.

  6. #6
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    thanks everyone. i'll try to have some fun with SDL, though most of my time will be spent working on my text adventure until I complete that... I'm almost there!
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  2. SDL + Newbie
    By Livijn in forum Game Programming
    Replies: 7
    Last Post: 04-30-2007, 11:20 PM
  3. SDL and MinGW Studio
    By Vicious in forum Tech Board
    Replies: 0
    Last Post: 07-30-2004, 09:59 PM
  4. an odd SDL problem...
    By DavidP in forum Game Programming
    Replies: 2
    Last Post: 03-14-2004, 10:01 AM
  5. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 10:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21