可以在 Linux 上使用 .dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2538635/
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
Possible to use a .dll on Linux
提问by random_hero
Question:Is it possible to compile a program on linux using a .dll file?
问题:是否可以使用 .dll 文件在 linux 上编译程序?
Where this is going:This .dll will be used to write a php extension to some proprietary software from a third party.
去向:这个 .dll 将用于为第三方的某些专有软件编写 php 扩展。
Background and Research:
背景和研究:
I have been given a library called proprietary.lib
. I was curious, as I have never seen the .lib
extension before, so I typed:
我得到了一个名为proprietary.lib
. 我很好奇,因为我以前从未见过.lib
扩展名,所以我输入:
file proprietary.lib
The output was:
输出是:
proprietary.lib: current ar archive
I did some research and found that ar
is more-or-less tar
(and in fact, I guess tar
has since replaced ar
in most *nix environments).
我做了一些研究,发现这ar
或多或少tar
(事实上,我猜tar
已经ar
在大多数 *nix 环境中取代了)。
Upon inspecting the ar
manpage, I saw the t option
, which displays a table listing of the contents of that archive. Cool. So I type:
在检查ar
联机帮助页时,我看到了t option
,它显示了该存档内容的表格列表。凉爽的。所以我输入:
ar t proprietary.lib
And get:
并得到:
proprietary.dll
proprietary.dll
... (snip X lines) ...
采纳答案by Broam
You could try extracting the ar
file (Debian packages are ar
files, fwiw) and run file
on the contents.
您可以尝试提取ar
文件(Debian 软件包是ar
文件,fwiw)并运行file
其中的内容。
You're not going to be able to use Windows DLLs without translation. The only DLL files that I know of that work natively on Linux are compiled with Mono.
如果不进行转换,您将无法使用 Windows DLL。我所知道的唯一可以在 Linux 上本地运行的 DLL 文件是用 Mono 编译的。
If someone gave you a proprietary binary library to code against, you should verify it's compiled for the target architecture (nothing like trying to use am ARM binary on an x86 system) and that it's compiled for Linux.
如果有人给了你一个专有的二进制库来编码,你应该验证它是为目标体系结构编译的(这与尝试在 x86 系统上使用 ARM 二进制文件不同)并且它是为 Linux 编译的。
That being said...good luck. I hate programming against third-party libraries where I have the documentation andthe source.
话虽这么说……祝你好运。我讨厌针对我有文档和源代码的第三方库进行编程。
回答by Martin Beckett
.dll files are usually Windows shared libraries. (It's also possible that somebody on Linux has built a regular Linux library and called it .dll for some reason.)
.dll 文件通常是 Windows 共享库。(也可能有人在 Linux 上构建了一个常规的 Linux 库,并出于某种原因将其命名为 .dll。)
It's possible you could link against them using Wine. Support for this was once in there as experimental - I don't know its current status.
您可以使用Wine链接它们。对此的支持曾经是实验性的 - 我不知道它的当前状态。
回答by Ber
Recent development may have changed the situation: There is a loadlibraryfunction for Linux available, that makes it possible to load a Windows DLL and then call functions within.
最近的发展可能改变了这种情况:有一个适用于 Linux的loadlibrary函数可用,它可以加载 Windows DLL,然后调用其中的函数。
So, if the .dll
file you have actually is a Windows DLL, you may find a way to use it in you software.
因此,如果.dll
您拥有的文件实际上是 Windows DLL,您可能会找到一种在您的软件中使用它的方法。
回答by Gopirathnam Gounder
Yes We can use dll with the help of wine . just install wine64 in linux
是的,我们可以在 wine 的帮助下使用 dll。只需在linux中安装wine64
sudo apt-get install wine64
回答by Sasinosoft
Normal DLL files are Windows' linked libraries, so they cannot run on Linux directly, however it's possible to compile DLL files specifically for Linux using .NET Core.
普通的 DLL 文件是 Windows 的链接库,因此它们不能直接在 Linux 上运行,但是可以使用 .NET Core 专门为 Linux 编译 DLL 文件。