SDL错误LNK1120:1个未解析的外部

时间:2012-11-06 23:12:40

标签: c++ opengl sdl

我正在尝试使用此代码测试SDL:

#include <SDL.h>

int main(int argc, char** argv){

    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Surface * screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
    bool IsRuning = true;
    Uint32 Start;
    SDL_Event Event;

    while (IsRuning)
    {
        Start = SDL_GetTicks();
        while (SDL_PollEvent(&Event))
        {
            switch (Event.type)
            {
            case SDL_QUIT:
                IsRuning = false;
                break;
            default:
                break;
            }
        }
        if(1000/30 > (SDL_GetTicks() - Start))
            SDL_Delay(1000/30 > (SDL_GetTicks() - Start));
    }

    SDL_Quit();
    return 0;
}

并且正在连接这些libs:

SDLmain.lib
SDL.lib
OpenGL32.lib
glu32.lib

当我尝试调试它时,它给了我那些错误: -

Warning 1   warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library    c:\Users\administrator\documents\visual studio 2010\Projects\TestSDL\TestSDL\MSVCRTD.lib(cinitexe.obj)

Error   2   error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function _redirect_output   c:\Users\administrator\documents\visual studio 2010\Projects\TestSDL\TestSDL\SDLmain.lib(SDL_win32_main.obj)

Error   3   error LNK1120: 1 unresolved externals   c:\users\administrator\documents\visual studio 2010\Projects\TestSDL\Debug\TestSDL.exe  1

这里缺少什么?!!

2 个答案:

答案 0 :(得分:1)

可能是针对SDLmain.lib的{​​{1}}或SDL.lib链接之一,这是MicroSoft Visual C RunTime库。但是,您正在编译调试版本,而调试版本取决于运行时库的调试版本。这两个运行时库,它们是冲突的。

解决方案是使用SDL库的特定调试版本。

答案 1 :(得分:0)

我有同样的问题。您需要更改该行:

int main(int argc, char** argv)

int main(int argc, char* argv)