Lazy Foo' Productions

Setting up SDL Extension Libraries on Visual Studio 2019 Community

Last Updated 8/12/22
1)First thing you need to do is download SDL_image headers and binaries. You will find them on the SDL_image website, specifically on this page.

You'll want to download the Visual C++ development libraries.
Extact the folder to where ever you'd like. I recommend keeping your development libraries in the same directory so for this tutorial we will be extacting it to C:\vclib

2)Now go download the source for lesson 06. Add the source file to your existing SDL2 project and hit build. You should get the following error:

Cannot open include file: 'SDL_image.h': No such file or directory

Like before, this mean Visual C++ can't find the SDL_image headers, so make sure to add the SDL_image headers to your path:
3) Try and build again. You'll probably get the following error:

unresolved external symbol IMG_Init referenced in function "bool __cdecl init(void)" (?init@@YA_NXZ)

Again, this means Visual Studio does not know it needs to use the SDL_image library, so go add it to your dependencies:

4)Build again and you'll get this error:

cannot open file 'SDL2_image.lib'

This is Visual C++ complaining that it can't find the SDL_image library file, so let's add it to library directories. Again, make sure you pick the library that matches your build configuration (for this tutorial we are using the Debug x64 configuration):

5)Build one more time and it should compile, but if you try to run you'll get this error:

The code execution cannot proceed because SDL2_image.dll was not found.

This is Windows complaining that it can't find SDL2_image.dll along with the other SDL2_image dlls. Let's add it to the path environment variable like we did for SDL
6)Restart Visual C++ so it can get the updated path variable, and the application should run.

Now that you have the extension library compiling, it's time to go onto part 2 of the tutorial.
Extension Libraries and Loading Other Image Formats Part 2: Loading PNGs with SDL_image