0

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.
Nasir Jones
  • 61
  • 1
  • 9

1 Answers1

3

Did you link against the SDL.dll?

Here is explained how you do that.

Cheers,
lindebear

Community
  • 1
  • 1
lindebear
  • 167
  • 10
  • Well, basically when you're using `LoadLibrary` you are linking... that's what DLL stands for DLL -> Dynamic Link Library. :D – lindebear Dec 11 '15 at 05:43
  • For the record I know what DLL stands for, and I know the difference between a statically linked library and a dynamically linked one. Yet, for some reason I was still stupid enough to forget to link the DLL. Thanks for helping me with this stupid blunder, really appreciate it :). – Nasir Jones Dec 11 '15 at 08:33
  • Well in that case I apologize for telling you again! haha :D – lindebear Dec 12 '15 at 03:29