简体   繁体   中英

MS visual studio 2013 SDL not working

I am using SDL in my project but I ran into a problem. I followed a tutorial on how to include SDL in MS visual studio here but it did not help. Here are the steps that I took.

First, I added the SDL input directory in C/C++ / General "Additional input directories" block:

Second, I added the SDL lib directory in Linker / General "Additional library directories" block:

Third, I added SDL2.lib;SDL2main.lib to the "Additional dependencies" section under Linker / input:

And last, I set the subsystem section under Linker / system to 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.

Your error:

Build started: Project: Project2, Configuration: Debug Win32

But your library directory that you've set has x64 as the subdirectory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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