Android Native - when to use 64bit NDK?

According to the official NDK download page: http://goo.gl/vI7Oek there are two target versions:

  • x86 target
  • x64 target

And I was wondering (as a novice in the NDK materials), does this mean that I should use the x64 NDK when compiling the application for devices equipped with x64 processors?

And if I need only one ".apk" file, how can it contain both x86 and x64 assemblies? (if possible, of course)

+6
source share
1 answer

Update: The question is a bit outdated. Starting with version 10c NDK is again distributed in one package for all target platforms . The answer has been updated to reflect this fact.


First of all, you must distinguish between the architecture of the device on which your application will run (which can be ARM (several types) 32 or 64 bits, MIPS 32 or 64 bits and Intel x86 / x64) and the architecture / OS of your build machine (which can be Windows, Linux or Mac, everything works on Intel x86 / x64 processors).

So, suppose you have Windows 64 bit. Then (since the latest version is 10d ), you should download android-ndk-r10d-windows-x86_64.exe . This will allow you to create for all target platforms supported by the NDK (32 and 64 bit).

If you create a 32-bit target device, the application will also work on a 64-bit device, because all of the listed 64-bit architectures are backward compatible with their 32-bit counterparts.

But if you want to use the 64-bit specific functions of the target architecture, you must use the 64-bit toolchains. If you create only for 64 bits, the application will not work in 32-bit architecture.

If you need to support several goals (for example, ARM and Intel x86), in Application.mk you can specify the goals for which you want your own code to be created (google for APP_ABI ), so you will build several versions of the built-in library, and the system will download the corresponding file at runtime. You can also provide separate binaries for the 32-bit and 64-bit versions of the same family, so you can fine-tune them.

In addition, you can read documents inside the NDK package, they are quite comprehensive.

+19
source

Source: https://habr.com/ru/post/976864/


All Articles