Home >Backend Development >C++ >Why Am I Getting Unresolved External Symbol Errors with SDL2 in Visual Studio 2015?
Unresolved External Symbol Errors with SDL2 in Visual Studio 2015
The "unresolved external symbol" errors reported by the linker indicate that the required symbols, __imp__fprintf and __imp____iob_func, are not defined or linked correctly in your program.
You have mentioned that you have linked all the necessary libraries (SDL2.lib and SDL2main.lib) correctly. However, the issue may lie in the different definitions of standard input/output (I/O) functions between Visual Studio 2015 and earlier versions.
In Visual Studio 2015, functions like printf, fprintf, and stderr are defined using __acrt_iob_func() instead of __iob_func(). This means that you may need to define __iob_func() yourself to return an array containing {stdin,stdout,*stderr}.
To resolve the unresolved external symbol errors for stdio functions, you can add legacy_stdio_definitions.lib to your linker options. This library will provide the necessary definitions for these functions in Visual Studio 2015.
In summary, the issue arises due to the change in the definitions of standard I/O functions in Visual Studio 2015. To fix the linker errors, define __iob_func() and add legacy_stdio_definitions.lib to your linker options.
The above is the detailed content of Why Am I Getting Unresolved External Symbol Errors with SDL2 in Visual Studio 2015?. For more information, please follow other related articles on the PHP Chinese website!