1

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.

ransh
  • 1,589
  • 4
  • 30
  • 56

1 Answers1

4

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.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Thx. But how is it that android can't run my "dynamic" build and it can run android.mk dynamic builds , while both builds uses the same Bionic ? and what does it mean standalone toolchain in NDK , does it mean building outside android studio ? – ransh Feb 14 '17 at 17:40
  • Android studio has nothing to do with this. You can use NDK on command line, just as well. The standalone toolchain works with regular GNU make files and toys, including `./configure`. I believe that your "dynamic" build uses glibc, and not bionic headers and libs. – Alex Cohn Feb 14 '17 at 17:57
  • I wasn't familiar that there is a standalone toolchain for android with the regular makefile. That's amazing. Thx. – ransh Feb 14 '17 at 19:21