20

Games that were made with Unity3D for Linux contains .dll files in their data folder GameDataFolder/Managed.

Which is weird because I thought that Linux uses .so files instead of .dll files.

(The same is true for Android-Unity3D apps too.)

Why?

0
25

The games you are speaking about are based on the .NET Framework and running with Mono, which is a free and open-source implementation of Microsoft's .NET Framework.

Because these applications are .NET based, Assemblies have .dll extension. So you can see DLL files in the folders.

One .NET program designed for cross-platform use can run on Windows, Linux or Mac, with the same "binaries" (including DLLs which are also assemblies), which are compiled in MSIL and need a .NET/Mono runtime to be executed.

Please note that you also have some free applications (not only games) based on Mono Framework available in Ubuntu repositories. For example: Tomboy.

9
  • 11
    Also note that those dll's aren't "real" windows dll's but actually compiled .NET bytecode. – Sanya_Zol Sep 9 '17 at 13:01
  • 5
    Also note that file extensions, including .dll and .so, are meaningless in Linux. They're only used for our convenience. – code_dredd Sep 9 '17 at 15:43
  • 1
    @ray Can you explain? I thought they are still a standard to convey file type information, hence aren't meaningless? – FMaz Sep 9 '17 at 16:36
  • 2
    @FynnMazurkiewicz: It's more a matter of slightly differing design traditions than a single central attribute that either system enforces. In fact, both the Windows kernel and the Linux dynamic linker will happily load a shared library (in their respective formats) no matter whether its filename ends in .dll or .so or something else. For historical reasons the LoadLibrary syscall in Windows will in some cases append ".dll" to the filename if it doesn't have an extension already, but that's not how it's typically used. – hmakholm left over Monica Sep 9 '17 at 17:08
  • 1
    @ray not quite: gcc won't find a library supplied like e.g. -lm if its file name doesn't end with .so or .a or versioned variants thereof. – Ruslan Sep 9 '17 at 21:57
9

The .dll files in GameDataFolder/Managed belong to a native code program that uses Mono internally.

The Unity game engine embeds Mono (even on most Windows platforms).

Cross-platform executables and shared libraries that can be run either by the .NET Common Language Runtime or Mono are often named with .exe and .dll suffixes, respectively, even when they are not specific to Windows. When you find a .dll file in a program for a GNU/Linux system like Ubuntu, or for any OS but Windows, this is usually why. Most of the time you find a .dll in an Ubuntu system, Golboth's answer explains it. But that's not quite what's going on here.

The Unity game engine--which should not be confused with the default graphical interface in most Ubuntu releases--is a popular proprietary cross-platform game engine. This engine does not run on top of the .NET Framework or Mono. Instead, it embeds Mono, which is to say that Mono runs on top of it. This is how developers write whatever code their game needs that is not already part of the Unity engine.

In general, Mono may be used the same way Microsoft's .NET CLR is usually used, to run complete .NET/Mono programs. But Mono is also designed to be easily embeddable in native code applications, including to enable those applications to be customized. That's what's going on in the situation you are describing. The files you're seeing do not belong to a program that runs directly on top of Mono or the .NET CLR. Instead they belong to a native-code program that embeds Mono.

How the Unity Game Engine Uses Mono

The Unity game engine, which is written mostly in C++, hosts its own instance of Mono, which does not use--and may be different from--the version (if any) installed through your system's package manager. This embedded Mono runtime cannot be used to run standalone .NET/Mono programs, because that is not its purpose. Instead, the native code portion of the engine uses it to run CIL code. (CIL is Common Intermediate Language, which is its official name. It was previously called MSIL or Microsoft Intermediate Language, since Microsoft developed it originally.) Programmers making games that use the Unity engine usually write their own code in C#, though some other languages are supported.

The Unity engine embeds Mono even in Windows. For Universal Windows Platform games--and no other platforms--it uses the Microsoft .NET Framework instead of Mono. But the majority of Unity games on most platforms, including most mobile devices and gaming consoles, and including Ubuntu and Windows, use Mono. On some platforms IL2CPP is available as an alternative to Mono, and on a few only IL2CPP is supported. See Scripting restrictions for details.

Other Situations Where You May See .dll Files On Ubuntu

Two situations where you are likely to see a .dll file on Ubuntu have been described:

  1. A shared library that is intended to be used by a .NET/Mono application. Golboth's answer describes this in detail. This is what most .dlls you'll see on an Ubuntu system are. It just does not happen to be what the .dll files in your GameDataFolder/Managed folder are for.
  2. A file providing code that is used by an embedded Mono runtime to provide "scripting" for a native code application. That's what's going on in this case.

There are two other reasonably common cases where you may see a .dll file on Ubuntu:

  1. The compiler for .NET Core produces .dll files rather than .exe files, even when what you are compiling is not a library. The .NET Core runtime (called CoreCLR), and not the regular .NET Framework or Mono, runs these files. .NET Core is a Microsoft product, but unlike the standard .NET Framework, .NET Core is cross-platform with official support for GNU/Linux systems like Ubuntu, and it is free open source software.
  2. Sometimes a .dll file you see on Ubuntu will just be a Windows library. You may see this if the program is being stored an Ubuntu system but run on Windows, or if you mount a Windows drive in Ubuntu. You may also see it in connection with programs that are able to be run on Ubuntu using Wine, including software that comes with Wine or that you install automatically with winetricks to support other Windows software.

This is not an attempt to exhaustively list all the circumstances where you may encounter a .dll on Ubuntu. (For example, it could also be an OS/2 library.) However, I believe those four cases are the most common ones.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.