Problem with static linking using MSVC in Windows

I am having problem with static linking using MSVC (2017) in Windows (10). My application is 64bit (x64).

I tried this solution:
Linking DLL’s into exe - SDL Development - Simple Directmedia Layer (

I added the following in sdl_config_windows.h:
#ifndef _WINDLL
#define HAVE_LIBC 1
Just before this line:
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */

I recompiled SDL2.24.1 to create static libraries (SDL2_static.lib and SDL2main_static.lib) using these command line options in Visual Studio.
/GS- /W3 /Zc:wchar_t /I"G:\Projects\SDL\SDL2\VisualC\SDL/…/…/include" /Z7 /Gm- /Od /Ob1 /Fd"x64\Debug\SDL2.pdb" /Zc:inline /fp:precise /D “DLL_EXPORT” /D “_DEBUG” /D “_WINDOWS” /D “_VC80_UPGRADE=0x0700” /errorReport:prompt /WX- /Zc:forScope /Gd /MTd /FC /Fa"x64\Debug" /EHsc /nologo /Zl /Fo"x64\Debug" /Fp"x64\Debug\SDL2.pch" /diagnostics:classic

/OUT:“G:\Projects\SDL\SDL2\VisualC\x64\Debug\SDL2_static.lib” /MACHINE:X64 /NOLOGO

It builds without errors and creates the two files (SDL2_static.lib and SDL2main_static.lib).

I added the following in my application linker input:
SDL2main_static.lib SDL2_static.lib version.lib Imm32.lib Setupapi.lib

The application links fine but somehow when I launch it, it still requests SDL2.dll?

Just to see if it would give me some clues, I tried supplying my application with the SDL2.dll version from the but then I get “The application was unable to start correctly (0xc000007b)”?

I also tried to statically link one of the test program from the solution (by adding the .lib mentioned above) and it works. I mean it runs and it is not asking for SDL2.dll which I deleted from the test program folder.