简体   繁体   English

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

[英]SDL error LNK1120: 1 unresolved externals

am trying to test SDL using this codes : 我正在尝试使用以下代码测试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;
}

and am linking this libs : 并链接此库:

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

when am trying to debug it it gives me those errors :- 当我尝试调试它时,给了我那些错误:-

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

what ma missing here?!! 这里缺少什么妈妈?!

Probably one of SDLmain.lib or SDL.lib links against msvcrt.lib , which is the MicroSoft Visual C RunTime library. 大概一个SDLmain.libSDL.lib对链接msvcrt.lib ,这是Microsoft Visual C运行时库。 However you're compiling a debug build, and debug builds depend on the debug variant of the runtime library. 但是,您正在编译调试版本,调试版本取决于运行时库的调试变量。 Those two runtime libraries, they are conflicting. 那两个运行库,它们是冲突的。

The solution would be to use specific debug builds of the SDL libraries. 解决方案是使用SDL库的特定调试版本。

I had the same issue. 我遇到过同样的问题。 You need to change the line: 您需要更改以下行:

int main(int argc, char** argv)

to

int main(int argc, char* argv)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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