Thread: a dumb question about SDL

  1. #1
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    a dumb question about SDL

    okay, I'm having a problem with SDL that should be an easy one for anyone who uses it to solve -> I #include "SDL.h" at the beginning of my program, that works fine, but I wrote the following function

    int initialize(void)
    {
    if(SDL_Init(SDL_INIT_VIDEO))
    {
    cout<<"Could not initialize SDL Video";
    exit(1);
    }
    screen = SDL_SetVideoMode(1280,1024, 24, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);
    if ( screen == NULL ) {
    fprintf(stderr, "Unable to set requested video mode: %s\n", SDL_GetError());
    exit(1);
    }
    return 0;
    }

    which is mostly code from the SDL site...it compiles fine, but I get the following linker errors...

    MAIN.OBJ : error LNK2001: unresolved external symbol _SDL_GetError
    MAIN.OBJ : error LNK2001: unresolved external symbol _SDL_SetVideoMode
    MAIN.OBJ : error LNK2001: unresolved external symbol _SDL_Init
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/3D Engine.exe : fatal error LNK1120: 5 unresolved externals

    What's wrong with it? Did I do something stupid and easily fixed (I hope)?

  2. #2
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403
    at a guess i'd say you havent included the library files.

  3. #3
    Registered User tgm's Avatar
    Join Date
    Jun 2002
    Posts
    150
    Yes, those are a result of missing .lib files. If you're in Windows you'll need SDLmain.lib and SDL.lib.
    With VC++ go to the project -> settings -> link tab and add those to the project/object modules line.

    Using Dev-C++ go to the project options, additional compiler options and add:
    -lmingw32 -lSDLmain -lSDL

  4. #4
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    if you are using Visual C++, make sure to change the settings to Multithreaded DLL. That must be there to compile.
    My Website

    "Circular logic is good because it is."

  5. #5
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    hmmm...I included the libraries that tgm told me to include, (btw, I'm using VC++), and I think I did what davidp was trying to tell me to do, but I haven't figured out where to put sdl.dll or even if that's what I need...I'm now getting these linker errors...

    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/3D Engine.exe : fatal error LNK1120: 2 unresolved externals

    I'd consult the documentation on VC++, but I don't have any (; Thanks for the help...

  6. #6
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    okay, guys, I declare myself an idiot...getting it to work was pretty easy after I found this online...so if anyone else out there is having any trouble with this ever, send 'em this link (:

    http://www.gamedev.net/reference/pro...features/sdl1/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Really really easy, dumb question
    By Hexadakota in forum C++ Programming
    Replies: 4
    Last Post: 04-07-2008, 04:03 PM
  2. dumb question
    By travis999 in forum C Programming
    Replies: 3
    Last Post: 10-26-2007, 12:57 AM
  3. Dumb question time - Winsock & accept()
    By jdinger in forum Networking/Device Communication
    Replies: 5
    Last Post: 06-11-2005, 01:08 AM
  4. Dumb question
    By fantim in forum C Programming
    Replies: 1
    Last Post: 03-03-2005, 01:48 AM
  5. another dumb question - loop not working?
    By Captain Penguin in forum C++ Programming
    Replies: 8
    Last Post: 10-06-2002, 10:15 PM