Why only static build run on Android?

273 Views Asked by At

I build some applications for android without using Android studio & NDK.

I've noticed that if I build them without "-static" arguments, then Android fails to run them.

I could not find the reason for that documented anywhere, though I guess that it relates to the fact that Android use Bionic and not glibc.

Is it because the Bionic libc requires static build, (In contrast to "standard Linux" glibc, which can handle dynamic build too) ? If so, then how is it that there are .so files in filesystem.

Thank you.

1

There are 1 best solutions below

3
On

You are right, the reason you need -static is because Bionic is not 100% compatible with glibc.

You can use NDK toolchain to build your apps, and then you can drop -static.

If you don't want to learn ndk-build system and use include $(BUILD_EXECUTABLE) in your Android.mk file, working with standalone toolchain in NDK is well documented.