Thread: Need help setting up SDL with MSVC

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    26

    Need help setting up SDL with MSVC

    Well I didn't have anywhere else to turn, so i came here. I dont know how many people here have actually worked with SDL, but I'm hoping there are a few of you out there that can help me.

    I downloaded the file under win32 I think, it ended with a VC6.zip. So I unzip it and find VisualC.html. I read it, and see it says how to compile your own files. (SDL.dll, SDL.lib, SDLmain.lib)
    I find a directory that already has them. So I skip this part and continue on. It tells me how to create a project with SDL. I follow the directions step by step. I then compile this.

    #include "SDL.h"

    int main( int argc, char* argv[] )
    {
    // Body of the program goes here.
    return 0;
    }

    I get 2 errors and a warning.
    LINK : warning LNK4001: no object files specified; libraries used
    LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
    Debug/SDL1.exe : fatal error LNK1120: 1 unresolved externals

    So I copy the first error and put it in a search engine. I find someone that gets the same error, due to using a borland lib instead of MSVC or something like this. So I go back to the first step to try and build my own.

    It says to unzip VisualC.zip to the same directory as the VisualC.html. I don't have a visualC.zip so I search libsdl.org and find a version 1.4 of the file and unzip it. It then says to go to the newly created Visual C directory, ok. Next I have to open the workspace "SDL.dsw", problem, "SDL_ttf.dsw" in this directory. I have no "SDL.dsw" anywhere. So I SDL_ttf.dsw instead. It then says to fileview on the workspace area and build the files by simply right clicking what I see in the area and choosing build. I should have a few warnings, but no errors. I get 1 error, and 1 warning for each. I can't figure out whats wrong. Help me somebody.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    26

    Update

    I found the real VisualC.zip I was looking for. It had the SDL.dsw. I compiled the 2 projects, and found the files in their debug folders. SDL.dll, SDL.lib, SDLmain.lib. I delete the files in my old project, put these new ones in. Recompile and get 2 errors and a warning. The same errors as before.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    26
    heh, I had actually given up. I was looking how I would use SDL with DevC++ when I saw a post in the libsdl.org newsgroup with the same error as mine. I read this:

    "The linker is looking for the entry point for a console application, but
    the application is being compiled and linked as a windows application (i.e.
    not a console application)."

    and decided I would try one last time. In VisualC.html they had been saying to use a Win32 application, so this time I tried win32 console app. and... IT WORKED!!!!!! I just made this point to let you all know that dreams do come tru

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    26
    ahhhhhhhhhhhhhhhhhhhh my dream jsut became a nightmare!!!!!!!!!

    #include "SDL.h"

    int main( int argc, char* argv[] )
    {
    // Body of the program goes here.
    return 0;
    }

    this compiled perfectly(got rid of those 2 errors, and warning above)

    below, hoever, leads me to more linker errors.
    SDLmain.lib(SDL_main.obj) : error LNK2001: unresolved external symbol _SDL_main
    Debug/SDLCAP1.exe : fatal error LNK1120: 1 unresolved externals

    int main() {

    printf("Initializing SDL.\n");

    /* Initialize defaults, Video and Audio */
    if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) {
    printf("Could not initialize SDL: %s.\n", SDL_GetError());
    return(-1);
    }

    printf("SDL initialized.\n");

    printf("Quiting SDL.\n");

    /* Shutdown all subsystems */
    SDL_Quit();

    printf("Quiting....\n");

    return(0);
    }

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    26
    ok i got it, it was the differences in the declaring main. I guess I have to have
    int argc, char *argv[], in my main from now on.

    I guess I will close down this thread now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Problems compiling this SDL app
    By Rider in forum C++ Programming
    Replies: 3
    Last Post: 03-27-2007, 12:22 PM
  3. setting msvc 6 to use unicode strings
    By reanimated in forum Windows Programming
    Replies: 6
    Last Post: 01-03-2004, 10:08 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. sdl in c++
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-07-2002, 07:46 AM