简体   繁体   English

未找到 SDL2.dll

[英]SDL2.dll was not found

I'm trying to set up SDL2 in C++ Visual Studio but when I run the code(just some starter code I copied) it pops up with an error box box that talks about "SDL2.dll cannot be found" I tried switching to x64 but that was no help.我正在尝试在 C++ Visual Studio 中设置 SDL2,但是当我运行代码(只是我复制的一些入门代码)时,它会弹出一个错误框框,内容是“找不到 SDL2.dll”,我尝试切换到 x64但这无济于事。 I can see that the dll is right next to the lib files but it just won't work.我可以看到 dll 就在 lib 文件旁边,但它不起作用。

Your problem is the lib folder is not a place that your OS will search for dependent dlls by default.你的问题是lib文件夹不是你的操作系统默认搜索依赖 dll 的地方。 To fix this you would have to help your OS find the dll. There are several methods you can use to tell your OS where to look.要解决此问题,您必须帮助您的操作系统找到 dll。您可以使用多种方法告诉您的操作系统去哪里查找。 One is adding an entry to your PATH environment variable that contains the full path to the folder containing the dll.一种方法是向 PATH 环境变量添加一个条目,其中包含包含 dll 的文件夹的完整路径。

This site can help with setting the PATH : https://www.computerhope.com/issues/ch000549.htm该站点可以帮助设置PATHhttps://www.computerhope.com/issues/ch000549.htm

As second method is to put the dll in the same folder as the executable.第二种方法是将 dll 放在与可执行文件相同的文件夹中。

By default your OS probably is using the safe search option described here :默认情况下,您的操作系统可能正在使用此处描述的安全搜索选项:


  1. The directory from which the application loaded.应用程序加载的目录。

  2. The system directory.系统目录。 Use the GetSystemDirectory function to get the path of this directory.使用 GetSystemDirectory function 获取此目录的路径。

  3. The 16-bit system directory. 16 位系统目录。 There is no function that obtains the path of this directory, but it is searched.没有function获取这个目录的路径,但是搜索了一下。

  4. The Windows directory. Windows 目录。 Use the GetWindowsDirectory function to get the path of this directory.使用 GetWindowsDirectory function 获取此目录的路径。

  5. The current directory.当前目录。

  6. The directories that are listed in the PATH environment variable. PATH 环境变量中列出的目录。 Note that this does not include the per-application path specified by the App Paths registry key.请注意,这不包括应用程序路径注册表项指定的每个应用程序路径。 The App Paths key is not used when computing the DLL search path.***计算 DLL 搜索路径时不使用 App Paths 键。***

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM