The latest version of SDL_stbimage.h includes some code conditional on the version of SDL, which is achieved as follows:
#if SDL_VERSION_ATLEAST(2, 0, 5)
Whilst this is fine when SDL2 is incorporated in a static build, it's problematical when an application is linked at runtime with a shared SDL2 library, such as SDL2.dll in Windows or libSDL2.so in Linux. This is because the conditional test is not checking the linked version of SDL2, but rather what headers happened to be used at compile time.
To ensure that such an application runs successfully with a shared version of SDL prior to 2.0.5 (unlikely, but possible with an old Windows or Linux installation) it would be necessary to perform the version check at run-time and use 'late binding' for the missing SDL_CreateRGBSurfaceWithFormatFrom() function to avoid a load-time error.
Indeed the version check would be superfluous, because getting the function address at run time with SDL_LoadObject() and SDL_LoadFuncition() would tell you whether it was available!
The latest version of SDL_stbimage.h includes some code conditional on the version of SDL, which is achieved as follows:
#if SDL_VERSION_ATLEAST(2, 0, 5)Whilst this is fine when SDL2 is incorporated in a static build, it's problematical when an application is linked at runtime with a shared SDL2 library, such as SDL2.dll in Windows or libSDL2.so in Linux. This is because the conditional test is not checking the linked version of SDL2, but rather what headers happened to be used at compile time.
To ensure that such an application runs successfully with a shared version of SDL prior to 2.0.5 (unlikely, but possible with an old Windows or Linux installation) it would be necessary to perform the version check at run-time and use 'late binding' for the missing
SDL_CreateRGBSurfaceWithFormatFrom()function to avoid a load-time error.Indeed the version check would be superfluous, because getting the function address at run time with
SDL_LoadObject()andSDL_LoadFuncition()would tell you whether it was available!