MonoGame application says SDL.dll is missing, even though it's there. Why?

試著忘記壹切 提交于 2019-12-05 14:31:27

Context:

Indeed, SDL.dll (from Assemblies/Linux) is a Win32 binary. The reason it's included in the "MonoGame for Linux" template is so that the game can run under Windows too. Under Linux, the DLL is not touched. Instead, Mono searches for a native Linux version of the SDL library. For some reason, however, it fails to map.

Solution:

  1. Make sure you have the libSDL library installed on your Linux system.
  2. Go to your project and add a file called Tao.Sdl.dll.config. This is because we want to write an application configuration file for the Tao.Sdl.dll assembly (because the call to SDL happens from inside Tao.Sdl.dll).
  3. Make sure the build action for this new file is Content and that it is copied to the output directory.
  4. Write the following in the new file (applicable for libSDL 1.2 - other versions may require different names):

    <?xml version="1.0" encoding="utf-8"?> <configuration> <dllmap dll="SDL.dll" target="libSDL-1.2.so.0" /> <dllmap dll="SDL_image.dll" target="libSDL_image-1.2.so.0" /> <dllmap dll="SDL_mixer.dll" target="libSDL_mixer-1.2.so.0" /> <dllmap dll="SDL_ttf.dll" target="libSDL_ttf-2.0.so.0" /> <dllmap dll="SDL_net.dll" target="libSDL_net-1.2.so.0" /> <dllmap dll="smpeg.dll" target="libsmpeg-0.4.so.0" /> <dllmap dll="SDL_gfx.dll" target="libSDL_gfx.so.4" /> </configuration>

  5. Clean and build.

Now Mono should have enough information to find libSDL on your system.

Indeed the solution you found solves the problem you faced, there is however an easier way to do it now.

  1. In your project install the Linux Nuget (https://www.nuget.org/profiles/MonoGame). This will automatically generate the necessary mappings.
  2. (possibly not necessary) The new Nugets should already remove any references that got added by default if you started a project from the Linux Template, but if not, remove those as instructed in the readme of the Nuget
  3. When running in the Linux OS you might then need to install some SDL related libraries that can depend on your system. For example, in my case (debian) I already had the libsdl1.2debian (supplying the "libSDL-1.2.so.0") but when I started the game it identified "libSDL_mixer-1.2.so.0" as missing and therefore I looked it up in an aptcache search and found the libsdl-mixer1.2 package. After installing it the game executed without a problem.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!