可共享库(。所以)专为Linux文件包含/链接,并在Android应用程序中使用? [英] Can a shared library (.so) file built for linux be included/linked and used in an Android application?

查看:166
本文介绍了可共享库(。所以)专为Linux文件包含/链接,并在Android应用程序中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目中,我需要包括 NGSpice 仿真库中的Andr​​oid应用程序和当然能够使用它。

I am working on a project in which I need to include NGSpice simulation library in an Android application and of course be able to use it.

我试过,包括NGSpice Windows动态链接库在我使用痛饮和Android NDK Android应用程序,但事实证明,这甚至是不可能的,所以现在我开始想建NGSpice作为的在Linux 的共享库。

I tried including the NGSpice windows DLL in my android application using SWIG and Android NDK, but it turned out that it is not even possible, so now I started to think about building NGSpice as a shared library for linux.

而现在我的问题是,我可以使用Linux共享库NGSpice因为它是在我的Andr​​oid应用程序,还是需要内置不同不知怎么的,在我的Andr​​oid应用程序。

And now my question is, can I use the linux shared library for NGSpice as it is in my Android application, or does it need to built differently somehow to work on my Android application.

感谢。

推荐答案

没有。 Android的通常具有传统的Linux两个关键的区别:

No. Android typically has two key differences from a traditional linux:

1),它采用了仿生C库和动态链接程序,而不是一个更传统的集合,例如glibc的。

1) It uses the Bionic C library and dynamic linker, instead of a more traditional set such as glibc.

2)的Andr​​oid通常在ARM或32位x86处理器(或在极少数情况下,MIPS)上运行,而你的桌面Linux库可能是任何64位或32位的x86 code。

2) Android is typically run on an ARM or 32-bit x86 processor (or in rare cases MIPS), while your desktop Linux library might be either 64-bit or 32-bit x86 code.

如果你用的机器和仿生的系统库函数和动态连接器架构的。所以兼容的,那么它应该是可行的。

If you build a .so compatible with the architecture of the machine and with bionic's system library functions and dynamic linker, then it should be workable.

另外,如果你有什么一个兼容的架构,但错的libc,它可能会写自己的装载机得到它到内存在安全设备上工作的形式,或植根设备上也可以运行更传统的Linux用户空间(通常是Debian的派生)在chroot。但是,这些都不是容易集成到一个Android应用程序 - 后者你几乎可以肯定要通过通过进程间通信工作过,并有可能在前者的情况下更容易证明,以及

Alternatively, if you have something for a compatible architecture but the wrong libc, it may be possible to write your own loader to get it into memory in working form on a secured device, or on a rooted device it is possible to run a more traditional linux userspace (typically Debian derived) in a chroot. But neither of these would be easy to integrate into an Android application - for the latter you'd almost definitely have to pass work over via interprocess communication, and that might prove easier in the former case as well.

您才真正认可的解决办法是重新从源代码库中,无论使用NDK构建系统,或NDK生成的独立工具链与图书馆的当前版本系统。

这篇关于可共享库(。所以)专为Linux文件包含/链接,并在Android应用程序中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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