Thread: SDL on visual studio errors! i need help!

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    SDL on visual studio errors! i need help!

    hey guys, i have been trying to get SDL to work so i can make a game but i cant for the life of me get it to work! i am on visual studio 2012 and i have done everything they say to do on lazyfoo.net on how to install SDL, here is my code:

    main.cpp:

    Code:
    #include"SDL.h"intmain( intargc, char* args[] ){    //Start SDL    SDL_Init( SDL_INIT_EVERYTHING );        //Quit SDL    SDL_Quit();        return 0;    }
    source:
    Code:
    #include"SDL.h"constint WINDOW_WIDTH = 640;constint WINDOW_HEIGHT = 480;constchar* WINDOW_TITLE = "SDL Start"; intmain(intargc, char **argv){   SDL_Init( SDL_INIT_VIDEO );    SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0,       SDL_HWSURFACE | SDL_DOUBLEBUF );   SDL_WM_SetCaption( WINDOW_TITLE, 0 );    SDL_Surface* bitmap = SDL_LoadBMP("\resources\sprites\MONO\spr_MONO.bmp");    // Part of the bitmap that we want to drawSDL_Rect source;   source.x = 24;   source.y = 63;   source.w = 65;   source.h = 44;    // Part of the screen we want to draw the sprite toSDL_Rect destination;   destination.x = 100;   destination.y = 100;   destination.w = 65;   destination.h = 44;    SDL_Event event;   bool gameRunning = true;    while (gameRunning)   {      if (SDL_PollEvent(&event))      {          if (event.type == SDL_QUIT)         {            gameRunning = false;         }      }       SDL_BlitSurface(bitmap, &source, screen, &destination);       SDL_Flip(screen);   }    SDL_FreeSurface(bitmap);    SDL_Quit();    return 0;}
    and this is what i am getting when i run it:
    Code:
    1>------ Build started: Project: MONO, Configuration: Debug Win32 ------
    1>Source.obj : error LNK2005: _SDL_main already defined in main.obj
    1>main.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
    1>Source.obj : error LNK2001: unresolved external symbol _SDL_Init
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol _SDL_Init
    1>main.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
    1>Source.obj : error LNK2001: unresolved external symbol _SDL_Quit
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol _SDL_Quit
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_Flip referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_FreeSurface referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_UpperBlit referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function _SDL_main
    1>Source.obj : error LNK2019: unresolved external symbol _SDL_PollEvent referenced in function _SDL_main
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_SetModuleHandle referenced in function _main
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_GetError referenced in function _main
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_strlcpy referenced in function _main
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_getenv referenced in function _WinMain@16
    1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_strlcat referenced in function _redirect_output
    1>C:\...\MONO\Debug\MONO.exe : fatal error LNK1120: 15 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    i have the SDL.dll, SDL.lib, and the SDLmain.lib in \MONO\Debug and here is what i did in the properties: SDL on visual studio errors! i need help!-microsoft-visual-studio-2-pngSDL on visual studio errors! i need help!-microsoft-visual-studio-3-pngSDL on visual studio errors! i need help!-microsoft-visual-studio-4-pngSDL on visual studio errors! i need help!-microsoft-visual-studio-pngthan in linker -> additional dependence i have "SDLmain.lib"if you can help me that would be great! thank you so much!

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    Hey!

    SDL is always tempermental when you first set it up. I have read articles on SDL being strict on the naming of the entry point. Maybe you could try:

    Code:
    int main(int argc, char *argv[])
    You also have to make sure you are linking all your files correctly and using the proper includes (which it appears you are doing). On the other hand your code looks very unformatted which also conerns me.

    Here is a decent wiki link for common SDL issues. Maybe you can locate the solution in there.
    FAQWindows - SDL Wiki...

    Good luck!
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

  3. #3
    Registered User hex_dump's Avatar
    Join Date
    Dec 2012
    Posts
    88
    I don't code on windooze but I found the following link helpful. Lazy Foo' Productions

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    what on earth happened to the 'source code' formatting??

    You need to start with the smallest possible executable that will open your SDL context, forget everything except launching a blank sdl surface window.

    At least that way very little else can be questioned in the program
    Last edited by rogster001; 03-20-2013 at 01:06 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-17-2011, 12:47 PM
  2. Visual C++ and Visual Studio 2010
    By 03jh01 in forum C++ Programming
    Replies: 5
    Last Post: 10-03-2010, 04:03 AM
  3. Visual Studio 2005 - Debug code with compile errors?
    By Swerve in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-17-2008, 08:12 AM
  4. visual studio 6 and visual studio.net difference
    By gemini_shooter in forum Tech Board
    Replies: 5
    Last Post: 02-04-2006, 01:32 AM
  5. Replies: 1
    Last Post: 05-26-2004, 09:59 AM