Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build solution in release mode for SDL library on VS 2019

enter image description here

I tried to download the SDL library from this particular link https://www.youtube.com/watch?v=PTQkCRxr6lk&t=194s .However I stumbled upon a "fatal error" and I have no clue what to do in order to solve it.

Here's what error I got:

1>------ Build started: Project: SDL2, Configuration: Release x64 ------
2>------ Skipped Build: Project: uninstall, Configuration: Release x64 ------
2>Project not selected to build for this solution configuration 
1>   Creating library D:/Media/Downloads/SDL2-2.0.10/Build/Release/SDL2.lib and object D:/Media/Downloads/SDL2-2.0.10/Build/Release/SDL2.exp
1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
1>D:\Media\Downloads\SDL2-2.0.10\Build\Release\SDL2.dll : fatal error LNK1120: 1 unresolved externals
1>Done building project "SDL2.vcxproj" -- FAILED.
3>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
3>Project not selected to build for this solution configuration 
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 2 skipped ==========
like image 524
Neri-kun Avatar asked Jan 01 '23 14:01

Neri-kun


1 Answers

@Neri-kun I ran into exactly the same problem when building SDL2 on VS2019. It seems that memset is in vcruntime.dll, which is not included in CMakeLists.txt. So find the following part in CMakeLists.txt and add vcruntime to the EXTRA_LIBS. Problem solved:

   # Libraries for Win32 native and MinGW
-  list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 shell32)
+  list(APPEND EXTRA_LIBS vcruntime user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 shell32)
like image 84
Michael Chen Avatar answered Jan 04 '23 02:01

Michael Chen