Possible to use a .dll on Linux

耗尽温柔 提交于 2020-01-01 02:10:13

问题


Question: Is it possible to compile a program on linux using a .dll file?

Where this is going: This .dll will be used to write a php extension to some proprietary software from a third party.

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:

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).

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 proprietary.lib

And get:

proprietary.dll
proprietary.dll
... (snip X lines) ...

回答1:


You could try extracting the ar file (Debian packages are ar files, fwiw) and run file on the contents.

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.

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.

That being said...good luck. I hate programming against third-party libraries where I have the documentation and the source.




回答2:


Recent development may have changed the situation: There is a loadlibrary function for Linux available, that makes it possible to load a Windows DLL and then call functions within.

So, if the .dll file you have actually is a Windows DLL, you may find a way to use it in you software.




回答3:


.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.)

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.




回答4:


Yes We can use dll with the help of wine . just install wine64 in linux

sudo apt-get install wine64



回答5:


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.



来源:https://stackoverflow.com/questions/2538635/possible-to-use-a-dll-on-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!