Android的NDK可以包含一个Windows DLL到一个Android共享库? [英] Can Android NDK include a windows dll to a an Android shared library?

查看:120
本文介绍了Android的NDK可以包含一个Windows DLL到一个Android共享库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它甚至有可能链接/包括在NDK-build命令一个dll文件,并生成可在Android的Java code访问DLL函数的共享库。

Is it even possible to link/include a dll file in the ndk-build command and produce a shared library that can access dll functions from android java code.

我一直在试图做到这一点,我试图用SWIG来创建一个Java包装code到DLL和我没有成功的话,我就开始觉得它甚至有可能!

I have been trying to do it, I tried to use SWIG to create a java wrapper code to dll and I didn't succeed, then I started to think is it even possible!

感谢。

推荐答案

没有。一个Windows DLL是在不同的格式的Andr​​oid和Linux。

No. A Windows DLL is in a different format to Android and Linux.

Windows使用称为PE COFF格式:可移植可执行,通用对象文件格式。虽然COFF本身来自UNIX,微软有自己的版本。进一步的不兼容性为了支持.NET对象存在。大多数UNIX的和Linux使用ELF - 执行和链接格式。

Windows uses a format known as PE COFF: "Portable Executable, Common Object File Format". Although COFF itself comes from UNIX, Microsoft has its own version. Further incompatibilities exist in order to support .Net objects. Most UNIX's and Linux use ELF - Execute and Link Format.

即使他们是由某种奇迹,用同样的格式,它可能仍然是行不通的,因为机器结构必须是相同的,例如ARM(也有ARM的几种配置)或Intel的x86。

Even if they were, by some miracle, using the same format, it probably still would not work, because the machine architectures would have to be the same, e.g. ARM (and there are several configurations of ARM) or Intel x86.

还有更多。即使你设法让运行DLL,它使用什么呢? DLL文件往往还有其他外部依赖,比如C运行时库,MSVCRT,或 kernel.dll

And there's more. Even if you managed to get the DLL to run, what else does it use? DLLs often have other external dependencies, for example the C runtime library, MSVCRT, or kernel.dll.

所以,就得到了源$ C ​​$ c和本地重新编译它?可能的工作,但Windows的DLL有时有一个可选的的DLLMain()入口点的Linux 的.so 文件没有直接的当量。怎么样code的休息吗?难道是写在一个可移植的方式?它是否坚持使用整个ISO语言标准?要真正的便携,code已经被设计和书面的方式。

So, get the source code and recompile it natively? That might work, but Windows DLLs sometimes have an optional DLLMain() entry point which Linux .so files have no direct equivalent. What about the rest of the code? Is it written in a portable manner? Has it stuck to using the ISO language standard throughout? To be truly portable, code has to be designed and written that way.

这篇关于Android的NDK可以包含一个Windows DLL到一个Android共享库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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