Linux 系统上的 Windows DLL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4569591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:52:52  来源:igfitidea点击:

Windows DLL on Linux System

javac++windowslinuxdll

提问by Lobo

I wonder if you can load a DLL, of Windows operating system (for example, user32.dll), in an application(in any programming language) with a Linuxoperating system.

我想知道您是否可以在具有Linux操作系统的应用程序(任何编程语言)中加载Windows 操作系统(例如 user32.dll)的 DLL

The DLL would be in a directory on the Linux file system.

DLL 将位于 Linux 文件系统上的目录中。

Thanks for the help.

谢谢您的帮助。

Greetings!

你好!

采纳答案by Brian Agnew

No. The architectures are fundamentally different.

不。架构根本不同。

I note your question is tagged C++. If it was a .net DLL (built with CLR bytecode) then you couldreference it via an application running under Mono.

我注意到你的问题被标记为 C++。如果它是一个 .net DLL(使用 CLR 字节码构建),那么您可以通过在 Mono 下运行的应用程序引用它。

回答by MarkR

Yes, you can load a DLL and call its functions by using an appropriate wrapper library, but that's fundamentally useless if the DLL itself has dependencies on the platform which are not present. This approach is used for things like closed-source video codecs, where no (nontrivial) dependencies exist.

是的,您可以使用适当的包装器库加载 DLL 并调用其函数,但是如果 DLL 本身对不存在的平台具有依赖性,那么这从根本上是无用的。这种方法用于诸如闭源视频编解码器之类的东西,其中不存在(非平凡的)依赖项。

User32.dll is of course, part of the OS and intrinsically linked to many NT kernel functions, none of which exist in Linux. Wine does not make use of the Windows user32.dll, but provides its own version which gives equivalent functionality.

User32.dll 当然是操作系统的一部分,并且与许多 NT 内核函数有着内在的联系,而这些函数在 Linux 中都不存在。Wine 不使用 Windows user32.dll,但提供了它自己的版本,该版本提供了等效的功能。

Loading Windows' user32.dll would definitely not be useful, as it is mostly going to be a wrapper for other DLLs, processes (for example CSRSS) and kernel calls which aren't present under Linux. You could load and use Wine's one though.

加载 Windows 的 user32.dll 肯定没有用,因为它主要是其他 DLL、进程(例如 CSRSS)和内核调用的包装器,这些在 Linux 下不存在。不过,您可以加载并使用 Wine 的一个。

回答by Keith

It's possible if you write a wrapper for it. That's how the win32 codecswork on Linux. Also Wineuses many DLLs.

如果你为它写一个包装器是可能的。这就是win32 编解码器在 Linux 上的工作方式。Wine还使用了许多 DLL。

回答by T.J. Crowder

You could probably do a custom Wine build (home page, Wikipedia page) for your application. We're talking about a bighammer here, though. :-)

您可能可以为您的应用程序进行自定义 Wine 构建(主页维基百科页面)。不过,我们在这里谈论的是一把锤子。:-)

回答by Cratylus

DLL is a format for windows (i.e. it MS implementation of shared library concept).
It is not in a format that Linux understands.
Linux uses the ELF format for dynamic libraries.

DLL 是 Windows 的一种格式(即它是共享库概念的 MS 实现)。
它不是 Linux 能够理解的格式。
Linux 使用 ELF 格式的动态库。

回答by Raedwald

Why do you want to do this? To execute a program (.exe) that uses that DLL? In that case you need a Windows emulator on your Linux machine, such as wine.

你为什么要这样做?要执行.exe使用该 DLL的程序 ( )?在这种情况下,您的 Linux 机器上需要一个 Windows 模拟器,例如wine