0
votes

so here's the problem I'm having. All of a sudden, implementing SDL just doesn't work anymore on vs 2013. To be more specific, anytime include the SDL standard header I get linker errors. I tried building my project with the following code:

#include <iostream>
#include <SDL.h>

SDL_Window *window;
SDL_GLContext context;

int main(int argc, char *argv[]){
    std::cout << "hello world" << std::endl;
    if (SDL_Init(SDL_INIT_EVERYTHING)){
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        window = SDL_CreateWindow("test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL&SDL_WINDOW_SHOWN);
        context = SDL_GL_CreateContext(window);
    }
    SDL_Delay(20000);
    SDL_GL_DeleteContext(context);
    SDL_DestroyWindow(window);
    system("pause");
    return 0;
}

I get the following errors:

  1. Error 1 error LNK2019: unresolved external symbol _SDL_CreateWindow referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  2. Error 2 error LNK2019: unresolved external symbol _SDL_DestroyWindow referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  3. Error 3 error LNK2019: unresolved external symbol _SDL_GL_SetAttribute referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  4. Error 4 error LNK2019: unresolved external symbol _SDL_GL_CreateContext referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  5. Error 5 error LNK2019: unresolved external symbol _SDL_GL_DeleteContext referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  6. Error 6 error LNK2019: unresolved external symbol _SDL_Delay referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  7. Error 7 error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\main.obj

  8. Error 8 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Open GL\MSVCRTD.lib(crtexe.obj)

  9. Error 9 error LNK1120: 8 unresolved externals C:\Users\Nas\Documents\Visual Studio 2013\Projects\Open GL\Debug\Open GL.exe

any help is appreciated :)

here's a list of things I already tried:

  1. undefining main ~> #undef main
  2. changing my subsystem to both windows and console (neither worked)
  3. Repeatedly cleaning and rebuilding my project.
1
where are you specifying the static SDL library to be linked with your project?edition

1 Answers

3
votes

Did you link against the SDL.dll?

Here is explained how you do that.

Cheers,
lindebear