未解析的外部符号 __imp__fprintf 和 __imp____iob_func,SDL2 [英] unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2

查看:19
本文介绍了未解析的外部符号 __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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆