0

所以,我是第一次尝试使用 SDL,但到目前为止它完全是一团糟!我试图让它运行,但我尝试过的一切都失败了。我一直在遵循所有正确的指南,但它仍然无法运行!

我正在使用Visual Studio Ultimate 2010.

这是我要运行的所有代码:

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

int main(int argc, char* args[]) {
    // Start SDL
    SDL_Init(SDL_INIT_EVERYTHING);

    std::cout << "SDL has been initialized!\n";

    // Quit SDL
    SDL_Quit();

    std::cout << "SDL has quit!" << std::endl;

    return 0x0;
}

编译器返回的错误让我发疯!他们来了:

1>------ Build started: Project: SDL_TEST, Configuration: Debug Win32 ------
1>Build started 7/6/2013 1:21:45 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\SDL_TEST.unsuccessfulbuild".
1>ClCompile:
1>  main.cpp
1>main.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
1>main.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
1>MSVCRT.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Tux\documents\visual studio 2010\Projects\SDL_TEST\Debug\SDL_TEST.exe : fatal error LNK1120: 3 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.59
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
4

1 回答 1

2

编译失败,因为您没有链接到正确的库。您已链接到 64 位库,但您正在尝试构建 Win32 二进制文件:

1>------ Build started: Project: SDL_TEST, Configuration: Debug Win32 ------

与 32 位库链接或切换到 Win64 二进制文件应该可以解决您的问题。

于 2013-07-06T18:10:26.357 回答