Like Tree2Likes
  • 1 Post By Lesshardtofind
  • 1 Post By rogster001

SDL on visual studio errors! i need help!

This is a discussion on SDL on visual studio errors! i need help! within the C++ Programming forums, part of the General Programming Boards category; hey guys, i have been trying to get SDL to work so i can make a game but i cant ...

  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: Name:  Microsoft Visual Studio 2.png
Views: 1051
Size:  57.0 KBName:  Microsoft Visual Studio 3.png
Views: 1020
Size:  54.1 KBName:  Microsoft Visual Studio 4.png
Views: 1027
Size:  54.2 KBName:  Microsoft Visual Studio.png
Views: 1015
Size:  50.2 KBthan 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
    407
    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!

  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,425
    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.
    Salem likes this.
    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, 11:47 AM
  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, 12:32 AM
  5. Replies: 1
    Last Post: 05-26-2004, 09:59 AM

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