Reputation:
I'm using Visual Studio 2013, and SDL 2.0.1, and for some reason, I get a whole bunch of errors similar to this:
Error 2 error LNK2019: unresolved external symbol _SDL_DestroyWindow referenced in function "public: virtual __thiscall Display::~Display(void)" (??1Display@@UAE@XZ) c:\Users\Toby\documents\visual studio 2013\Projects\OpenGLTutorialProject\OpenGLTutorialProject\Display.obj OpenGLTutorialProject
The steps I took to link SDL to my program: -Created a folder called include, and put all the files in SDL/include into my project's include folder. -Created a lib folder for my project, and put all the contents in SDL/lib into it. -Went to Properties -> Linker -> General -> Additional Library Directories and pointed it to my lib folder in the project. -Went to Properties -> C/C++ -> General -> AdditionalInclude Directories and set the path to my include folder in my project. -Went to Properties -> Linker -> Input-> Additional Dependencies and typed the following:
glew32.lib
glew32s.lib
SDL2.lib
SDL2main.lib
SDL2test.lib
OpenGL32.lib
Yes, I also included GLEW, which works fine and links.
When I type this:
#include<SDL2/SDL.h>
Visual studio actually completes it for me, so visual studio knows SDL exists in the project. However, after that, I try to run and compile, and I'm met with a bunch of unresolved external symbol errors, and then this:
Error 12 error LNK1120: 11 unresolved externals c:\users\toby\documents\visual studio 2013\Projects\OpenGLTutorialProject\Debug\OpenGLTutorialProject.exe OpenGLTutorialProject
I searched and it seems SDL used to have trouble with visual studio 2013, but then the bugs were ironed out. I also made sure to set up my main method like so:
int main(int argc, char **argv)
Because I have heard SDL is picky when it comes to arguments in the main method. Can anyone tell me what I have done wrong?
Upvotes: 0
Views: 2179
Reputation: 44891
My guess is that you are either using a incorrect path or linking against the wrong version of the libraries for your selected platform? ie x86 or x64?
If your compiler is set up for 32-bit you need to use the x86 libraries and not the x64.
Also, the Additional Library Directories
needs to point at the directory where the lib files are located, in SDL2 the lib directory has two sub directories for x86 and x64 respectively. If you copied everything from the SDL lib directory the files might have ended up where they shouldn't be.
Upvotes: 2