Home >Backend Development >C++ >Why Do I Get Unresolved External Symbols __imp__fprintf and __imp____iob_func in Visual Studio 2015 When Using SDL2?

Why Do I Get Unresolved External Symbols __imp__fprintf and __imp____iob_func in Visual Studio 2015 When Using SDL2?

DDD
DDDOriginal
2024-12-02 05:02:12354browse

Why Do I Get Unresolved External Symbols __imp__fprintf and __imp____iob_func in Visual Studio 2015 When Using SDL2?

Unresolved External Symbols: __imp__fprintf and __imp____iob_func in Visual Studio 2015

When compiling programs that use SDL2 in Visual Studio 2015, you may encounter unresolved external symbols __imp__fprintf and __imp____iob_func. This error indicates that the linker cannot resolve references to these symbols in the linked libraries.

Previously, Visual Studio defined standard I/O functions (stdin, stdout, stderr) using __iob_func() and its index. However, in Visual Studio 2015, the definitions changed, using __acrt_iob_func() instead. This change removed the direct reference to __iob_func(), leading to unresolved symbol errors when using libraries compiled with older versions of Visual Studio.

To solve this issue, you can either:

  • Define __iob_func() Yourself: Create a custom definition for __iob_func() that returns an array containing {stdin,stdout,*stderr}.
  • Add legacy_stdio_definitions.lib: Add this library to your linker options. It provides definitions for stdio functions that may be missing from your project.

After making these changes, recompile your code. The unexplained external symbols should no longer appear.

The above is the detailed content of Why Do I Get Unresolved External Symbols __imp__fprintf and __imp____iob_func in Visual Studio 2015 When Using SDL2?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn