简体   繁体   English

MS Visual Studio 2013 SDL无法正常工作

[英]MS visual studio 2013 SDL not working

I am using SDL in my project but I ran into a problem. 我在项目中使用SDL,但遇到了问题。 I followed a tutorial on how to include SDL in MS visual studio here but it did not help. 我跟着就如何以包括MS Visual Studio的SDL的教程在这里 ,但它并没有帮助。 Here are the steps that I took. 这是我采取的步骤。

First, I added the SDL input directory in C/C++ / General "Additional input directories" block: 首先,我在C / C ++ /常规“其他输入目录”块中添加了SDL输入目录:

Second, I added the SDL lib directory in Linker / General "Additional library directories" block: 其次,我在Linker / General“其他库目录”块中添加了SDL lib目录:

Third, I added SDL2.lib;SDL2main.lib to the "Additional dependencies" section under Linker / input: 第三,我在链接器/输入下的“其他依赖项”部分中添加了SDL2.lib; SDL2main.lib:

And last, I set the subsystem section under Linker / system to Console (/SUBSYSTEM:CONSOLE): 最后,我将链接器/系统下的子系统部分设置为控制台(/ SUBSYSTEM:CONSOLE):

This did not work, however, when I tried to run the test code that was supplied by the tutorial: 但是,当我尝试运行本教程提供的测试代码时,此方法不起作用:

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

int main(int argc, char **argv){
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
        return 1;
    }
    SDL_Quit();

    return 0;
}

because I got these build errors when I debugged: 因为我在调试时遇到了这些构建错误:

1>------ Build started: Project: Project2, Configuration: Debug Win32 ------
1>start.obj : error LNK2019: unresolved external symbol _SDL_GetError referenced in function _SDL_main
1>start.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
1>start.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>c:\users\holger\documents\visual studio 2013\Projects\Game\Debug\Project2.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I thought that I followed the tutorial well, but apparently not. 我以为我很好地遵循了本教程,但显然没有。 Please help me! 请帮我!

Thank you in advance! 先感谢您!

Cheers engineers 干杯工程师

The error seems to be that you're building a 32-bit application, but pointing to the 64-bit libraries. 错误似乎是您正在构建32位应用程序,但指向64位库。

Your error: 您的错误:

Build started: Project: Project2, Configuration: Debug Win32

But your library directory that you've set has x64 as the subdirectory. 但是您设置的库目录具有x64作为子目录。

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

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