我对SDL的简单介绍程序没有构建。为什么我会收到这些链接器错误?

时间:2013-07-06 17:31:57

标签: c++ visual-studio-2010 visual-c++ sdl linker-errors

所以,我第一次尝试使用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 ==========

1 个答案:

答案 0 :(得分:2)

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

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

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