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.
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!
Thanks.
No. Not without building a whole Windows compatibility layer. Android is not compatible with Windows out of the box.
Also, Windows DLLs tend to be compiled for Intel x86 CPUs, while the majority of Android devices have ARM CPUs. While Windows for ARM exists (Windows Phone, Windows RT to name some), the environment that the DLL is supposed to live in doesn't exist on Android.
No. A Windows DLL is in a different format to Android and Linux.
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.
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.
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
.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.