根据雷神教程中sdl的配置做下去还是会出现如下的问题
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: 无法解析的外部符号 __imp__fprintf,该符号在函数 _ShowError 中被引用
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: 无法解析的外部符号 __imp____iob_func,该符号在函数 _ShowError 中被引用

查了一下是如下的问题:
定义方式发生了变换,标准stdin,stderr,stdout定义如下:
#define stdin (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))
以前是这样定义的:
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
以上部分来自

博客介绍了在使用SDL2时遇到的链接错误,问题在于stdin、stdout和stderr定义方式的变化。解决方案是在代码中添加pragma comment来链接'legacy_stdio_definitions.lib'库,并定义stdio的全局变量。通过这些步骤,可以成功解决编译错误并使SDL2程序正常运行。
最低0.47元/天 解锁文章
1899






