gpt4 book ai didi

c++ - SDL 错误 LNK1120 : 1 unresolved externals

转载 作者:行者123 更新时间:2023-11-28 07:53:21 27 4
gpt4 key购买 nike

我正在尝试使用此代码测试 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

这里缺少什么?!!

最佳答案

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

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

关于c++ - SDL 错误 LNK1120 : 1 unresolved externals,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13260938/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com