无法在 VS 2019 上以 Release模式为 SDL 库构建解决方案

标签 c cmake sdl visual-studio-2019 unresolved-external

enter image description here

我尝试从此特定链接下载 SDL 库 https://www.youtube.com/watch?v=PTQkCRxr6lk&t=194s .但是我偶然发现了一个“ fatal error ”,我不知道该怎么做才能解决它。

这是我遇到的错误:

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 ==========

最佳答案

@Neri-kun 我在 VS2019 上构建 SDL2 时遇到了完全相同的问题。 memset似乎在vcruntime.dll中,CMakeLists.txt中没有。所以在CMakeLists.txt中找到下面的部分,将vcruntime添加到EXTRA_LIBS中。问题解决:

   # 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)

关于无法在 VS 2019 上以 Release模式为 SDL 库构建解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58288692/

相关文章:

c - 如何删除 Eclipse 工具栏中的启动配置栏?

c - 数字末尾的 `u` 是什么意思?

makefile - make 找不到 SDL_mixer.h 但我包含了 SDL 目录

sdl - 'SDL_JoystickOpened' 的 SDL-2.0 对应函数是什么?

c - 返回 x,其中从位置 p 开始的 n 位设置为 y 的最右边 n 位,其他位保持不变

c - 将 `log10(2)` 的结果分配给一个常量

android - ROLI JUCE Android CMake 错误,生成的空白演示应用程序无法在 Android Studio 中编译

C++链接器错误LNK2005已在SDL中定义

c++ - 将 Polycode 链接到 C++

c++ - 错误 : unable to handle compilation, 预期在 '' 中恰好有一项编译器作业 [clang-diagnostic-error]