Windows build fails with missing symbol __imp_CommandLineToArgvW

According to docs, “On Windows, SDL does not depend on a C runtime at all, not even for malloc(). This means it’s possible to build SDL with almost any Windows compiler and have it work with a program built with any other”. And according to this answer, it worked in 2016. But now, with latest buildbot artifacts sdl-visualstudio-4934.zip I get:

src> clang++ -std=c++11 hello.cpp -Isdl2\include -Lsdl2\lib\win64 -lsdl2main -lsdl2 -Xlinker /subsystem:console
sdl2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp_CommandLineToArgvW referenced in function main_getcmdline                                                                    
a.exe : fatal error LNK1120: 1 unresolved externals                                                                                                                                          
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

Could you suggest a fix please?

1 Like

sdl2main requires you to link to Shell32 since https://hg.libsdl.org/SDL/rev/a1917148d38a

4 Likes

Thank you! In VS2019, simply adding Shell32.lib to Properties>Linker>Input> Additional Dependencies did the trick! :smile:

1 Like