unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2(未解析的外部符号 __imp__fprintf 和 __imp____iob_func,SDL2)
问题描述
谁能解释一下
__imp__fprintf
__imp__fprintf
和
__imp____iob_func
__imp____iob_func
未解决的外部手段?
因为我在尝试编译时遇到这些错误:
Because I get these errors when I'm trying to compile:
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _ShowError
1>E:DocumentsVisual Studio 2015ProjectsSDL2_TestDebugSDL2_Test.exe : fatal error LNK1120: 2 unresolved externals
我已经可以说问题不在于链接错误.我已正确链接所有内容,但由于某种原因它无法编译.
I can already say that the problem is not from linking wrong. I have linked everything up correctly, but for some reason it won't compile.
我正在尝试使用 SDL2.
I'm trying to use SDL2.
我使用 Visual Studio 2015 作为编译器.
I'm using Visual Studio 2015 as compiler.
我已在链接器 -> 输入 -> 附加依赖项中链接到 SDL2.lib 和 SDL2main.lib,并且我已确保 VC++ 目录是正确的.
I have linked to SDL2.lib and SDL2main.lib in Linker -> Input -> Additional Dependencies and I have made sure that the VC++ Directories are correct.
推荐答案
我终于知道为什么会这样了!
I have finally figured out why this is happening !
在visual studio 2015中,stdin、stderr、stdout的定义如下:
In visual studio 2015, stdin, stderr, stdout are defined as follow :
#define stdin (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))
但以前,它们被定义为:
But previously, they were defined as:
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
所以现在 __iob_func 不再定义,这会导致在使用使用 Visual Studio 以前版本编译的 .lib 文件时出现链接错误.
So now __iob_func is not defined anymore which leads to a link error when using a .lib file compiled with previous versions of visual studio.
为了解决这个问题,你可以尝试自己定义 __iob_func()
,它应该返回一个包含 {*stdin,*stdout,*stderr}
的数组.
To solve the issue, you can try defining __iob_func()
yourself which should return an array containing {*stdin,*stdout,*stderr}
.
关于 stdio 函数的其他链接错误(在我的例子中是 sprintf()
),您可以将 legacy_stdio_definitions.lib 添加到您的链接器选项.
Regarding the other link errors about stdio functions (in my case it was sprintf()
), you can add legacy_stdio_definitions.lib to your linker options.
这篇关于未解析的外部符号 __imp__fprintf 和 __imp____iob_func,SDL2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未解析的外部符号 __imp__fprintf 和 __imp____iob_func,SDL2
基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01