简体   繁体   English

SDL错误Visual Studio 2013

[英]SDL errors Visual Studio 2013

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: 我正在使用Visual Studio 2013和SDL 2.0.1,由于某种原因,我得到了一大堆类似于此的错误:

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. 我将SDL链接到我的程序的步骤: - 处理一个名为include的文件夹,并将SDL / include中的所有文件放入我项目的include文件夹中。 -Created a lib folder for my project, and put all the contents in SDL/lib into it. 为我的项目处理了一个lib文件夹,并将所有内容放入SDL / lib中。 -Went to Properties -> Linker -> General -> Additional Library Directories and pointed it to my lib folder in the project. -转到属性 - >链接器 - >常规 - >其他库目录,并将其指向项目中的lib文件夹。 -Went to Properties -> C/C++ -> General -> AdditionalInclude Directories and set the path to my include folder in my project. -转到属性 - > C / C ++ - >常规 - > AdditionalInclude目录,并在我的项目中设置包含文件夹的路径。 -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. 是的,我还包括GLEW,它工作正常和链接。

When I type this: 当我输入这个:

#include<SDL2/SDL.h>

Visual studio actually completes it for me, so visual studio knows SDL exists in the project. Visual Studio实际上为我完成了它,因此visual studio知道SDL存在于项目中。 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. 我搜索过,似乎SDL曾经在使用visual studio 2013时出现问题,但随后出现了错误。 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. 因为我听说SDL在主方法中的参数方面很挑剔。 Can anyone tell me what I have done wrong? 谁能告诉我我做错了什么?

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? 即x86还是x64?

If your compiler is set up for 32-bit you need to use the x86 libraries and not the x64. 如果您的编译器设置为32位,则需要使用x86库而不是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. 此外, Additional Library Directories需要指向lib文件所在的目录,在SDL2中,lib目录分别有两个x86和x64子目录。 If you copied everything from the SDL lib directory the files might have ended up where they shouldn't be. 如果您从SDL lib目录复制了所有内容,那么文件可能已经结束了它们不应该存在的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM