Search code examples
androidandroid-ndkdynamic-linkingdylib

Use OSX .dylib with Android NDK


Is it possible to reference an Mac OS X .dylib in an Android.mk file, as we do for .so files?

I have a C++ project compiling on my computer that I need to use with the NDK. The project uses two dylib. The compilation works, but linking does not (I'm having "undefined reference to [...]" messages).


Solution

  • No, its not. A .dylib has a binary format that the underlying Linux OS doesn't understand. You need to use a .so file. Although if you have the source code for the library, compiling it to .so should require minimal changes, perhaps as little as a shim layer