Skip to content Skip to sidebar Skip to footer

Can A Shared Library (.so) File Built For Linux Be Included/linked And Used In An Android Application?

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. I tried including the NGSpice windows DLL

Solution 1:

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

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

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.

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.

Your only really endorsed solution is to rebuild the library from source, using either the ndk build system, or an ndk-generated "stand alone toolchain" and the library's current build system.

Post a Comment for "Can A Shared Library (.so) File Built For Linux Be Included/linked And Used In An Android Application?"