MonoGame应用说SDL.dll丢失,即使它的存在。为什么? [英] MonoGame application says SDL.dll is missing, even though it's there. Why?

查看:406
本文介绍了MonoGame应用说SDL.dll丢失,即使它的存在。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Visual Studio中的Linux游戏模板MonoGame应用程序构建。它无论是使用.NET或单声道运行在Windows,但它在Linux上失败。

I have a MonoGame application built using the Linux Game template in Visual Studio. It runs on Windows using either .NET or Mono, but it fails on Linux.

错误是 DllNotFoundException 关于SDL.dll但SDL.dll总是在二进制的目录。该文件不是一个CLR程序集,所以它不是在参考文献。相反,我把它从MonoGame的组件/ Linux目录生成过程中复制(和所有相关的CLR组件从该文件夹复制以及)。无论我已经建立了这个项目在Windows下在Visual Studio或Xamarin Studio或Linux下的MonoDevelop中出现的错误。 。有没有生成错误

The error is a DllNotFoundException concerning SDL.dll but the SDL.dll is always in the binary's directory. The file is not a CLR assembly, so it's not in the References. Instead, I have it copied during build from MonoGame's Assemblies/Linux directory (and all related CLR assemblies are copied from that folder as well). The error appears regardless of whether I've built the project under Windows in Visual Studio or Xamarin Studio or under Linux in MonoDevelop. There are no build errors.

下面是相关的堆栈跟踪:

Here's the relevant stack trace:

System.DllNotFoundException: SDL.dll
  at (wrapper managed-to-native) Tao.Sdl.Sdl:__SDL_InitSubSystem (int)
  at Tao.Sdl.Sdl.SDL_InitSubSystem (Int32 flags) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.OpenTKGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game..ctor () [0x00000] in <filename unknown>:0 

(我没有包含的代码,因为这并不需要做我的代码 - 它发生,即使我建立从模板新项目,我已经被谷歌搜索有关此小时,试图什么在各种论坛提出的所有组合,但我还没有找到一个解决办法。 )

(I haven't included code because this doesn't have to do with my code - it happens even if I build a fresh project from the template. I've already been googling for hours about this and have tried all combinations of what's proposed in various forums, but I haven't found a solution yet.)

我能做些什么来解决这个问题?

附录: MONO_LOG_LEVEL =调试,我可以看到运行时的企图找到该DLL,他们都说,文件未找到。当我尝试通过重命名文件到 libSDL.dll (或其他任何东西它找)帮助运行时提示无效的ELF头并忽略它。这可能是可以预料的,因为它看起来像一个Win32二进制(不是CLR程序集)。 !混乱

Addendum: With MONO_LOG_LEVEL=debug, I can see the runtime's attempts to locate the DLL and they all say that the file was not found. When I try to "help" the runtime by renaming the file to libSDL.dll (or anything else it's looking for) it says "invalid ELF header" and ignores it. Which is probably to be expected, since it looks like a Win32 binary (not a CLR assembly). Confusion!

推荐答案

上下文:

事实上,SDL.dll(从组件/ Linux)的是一个Win32的二进制文件。它列入MonoGame Linux的模板的原因是,这样的游戏可以在Windows下运行了。在Linux下,该DLL不感动。相反,单声道搜索本地Linux版本的SDL库。出于某种原因,但是,它不能映射

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.

解决方案:


  1. 确保您已安装的Linux系统上libSDL库。

  2. 转到您的项目并添加一个名为 Tao.Sdl.dll.config 。这是因为我们想要写的 Tao.Sdl.dll 组装应用程序配置文件(因为调用SDL从内 Tao.Sdl发生.DLL )。

  3. 确保这个新文件生成操作的内容,它被复制到输出目录。

  4. 将在新文件中的以下(适用于libSDL 1.2 - 其他版本可能需要不同的名称):

  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版本=1.0编码=UTF-8>?;
<结构>
< dllmap DLL =SDL.dll目标=libSDL-1.2.so.0/>
< dllmap DLL =SDL_image.dll目标=libSDL_image-1.2.so.0/>
< dllmap DLL =SDL_mixer.dll目标=libSDL_mixer-1.2.so.0/>
< dllmap DLL =SDL_ttf.dll目标=libSDL_ttf-2.0.so.0/>
< dllmap DLL =SDL_net.dll目标=libSDL_net-1.2.so.0/>
< dllmap DLL =smpeg.dll目标=libsmpeg-0.4.so.0/>
< dllmap DLL =SDL_gfx.dll目标=libSDL_gfx.so.4/>
< /结构>

清理并生成

现在单应该有足够的信息来找到libSDL您的系统上。

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

这篇关于MonoGame应用说SDL.dll丢失,即使它的存在。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆