0

我正在尝试使用以下代码测试 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;
}

并链接这个库:

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

这里缺少什么?!

4

2 回答 2

1

可能是 MicroSoft Visual C RunTime 库中的一个SDLmain.libSDL.lib链接。msvcrt.lib但是,您正在编译调试版本,并且调试版本取决于运行时库的调试变体。这两个运行时库,它们是冲突的。

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

于 2012-11-06T23:24:40.013 回答
0

我遇到过同样的问题。您需要更改行:

int main(int argc, char** argv)

int main(int argc, char* argv)
于 2014-04-04T08:10:44.907 回答