简体   繁体   English

Android Native - 何时使用64位NDK?

[英]Android Native - When to use 64-bit NDK?

According to NDK's official download page: http://goo.gl/vI7Oek there are two target versions: 根据NDK的官方下载页面: http//goo.gl/vI7Oek有两个目标版本:

  • x86 Target x86目标
  • x64 Target x64目标

And I was wondering ( as a newbie in the NDK stuff ), does this mean I should use the x64 NDK when compiling an application for devices equipped with x64 processors? 我想知道(作为NDK中的新手),这是否意味着我应该在为配备x64处理器的设备编译应用程序时使用x64 NDK?

And if I need only one ".apk" file, how to make it contain both x86 & x64 builds? 如果我只需要一个“.apk”文件,如何使它包含x86和x64版本? ( if possible of course ) (如果可能的话)

Update: The question is a bit outdated now. 更新:这个问题现在有点过时了。 Starting from version 10c NDK is distributed in a single package for all target platforms again . 从版本10c开始, NDK再次分布在所有目标平台的单个包中 The answer has been updated to reflect this fact. 答案已经更新,以反映这一事实。


First of all, you should distinguish between the architecture of the device where your application will run (which can be ARM (several kinds) 32 or 64 bit, MIPS 32 or 64 bit, and Intel x86 / x64) and the architecture/OS of your build machine (which can be Windows, Linux or Mac all running on Intel x86 / x64 processors). 首先,您应该区分运行应用程序的设备的架构(可以是ARM(几种)32或64位,MIPS 32或64位,以及Intel x86 / x64)以及架构/操作系统您的构建计算机(可以是运行在Intel x86 / x64处理器上的Windows,Linux或Mac)。

So suppose you have Windows 64 bit. 所以假设你有Windows 64位。 Then (as right now the latest version is 10d ) you should download android-ndk-r10d-windows-x86_64.exe . 然后(现在最新的版本是10d )你应该下载android-ndk-r10d-windows-x86_64.exe It will allow you to build for all target platforms supported by NDK (32 and 64 bit). 它将允许您为NDK支持的所有目标平台(32位和64位)构建。

If you build for 32-bit target device, the application will run on 64-bit device as well, because all listed 64-bit architectures are backward compatible with their 32-bit counterparts. 如果为32位目标设备构建,则应用程序也将在64位设备上运行,因为所有列出的64位体系结构都向后兼容其32位对应设备。

But if you want to use 64-bit specific features of target architecture, you should use 64-bit toolchains. 但是,如果要使用目标体系结构的64位特定功能,则应使用64位工具链。 If you build only for 64 bits, the application won't run on 32-bit architecture. 如果仅为64位构建,则应用程序将无法在32位体系结构上运行。

If you have to support several targets (like ARM and Intel x86), in your Application.mk you can specify targets which you want your native code to be built for (google for APP_ABI ), so you'll build several versions of native library and the system will load the appropriate one in runtime. 如果你必须支持几个目标(比如ARM和Intel x86),你可以在Application.mk中指定你想要为你的本机代码构建的目标(google for APP_ABI ),这样你就可以构建几个版本的本机库并且系统将在运行时加载适当的一个。 Also this way you can provide separate binaries for 32 and 64 bit versions of same architecture family, so you may fine-tune them. 此外,您可以为同一架构系列的32位和64位版本提供单独的二进制文件,因此您可以对它们进行微调。

You may further read the docs inside NDK package, they are quite exhaustive. 您可以进一步阅读NDK包中的文档,它们非常详尽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Android Studio配置为使用NDK(android-ndk-r10d,Windows 64位) - Configuring Android Studio to use NDK (android-ndk-r10d, Windows 64-bit) 为什么Android NDK对于32位和64位ABI使用不同的GCC版本? - Why does the Android NDK use different GCC versions for 32-bit and 64-bit ABIs? 哪些版本的Android NDK支持64位体系结构? - Which versions of the Android NDK support 64-bit architectures? 如何在64位Android设备上使用32位本机库 - How to use 32-bit native libraries on 64-bit Android device 在 64 位 android 上使用 32 位 jni 库 - Use 32-bit jni libraries on 64-bit android 反应原生Android 64位升级问题 - React Native Android 64-bit upgrading issue 为android 64位arm架构构建本机代码 - build native code for android 64-bit arm architecture DS-5版,用于使用Arm 64位和32位本机库开发和调试Android应用 - DS-5 edition to develop and debug Android Apps with Arm 64-bit and 32-bit native libraries 在64位Android设备上从Google Play商店安装应用时,如果该应用支持,该应用是否以64位安装? - When installing an app from the Google Play store on a 64-bit Android device, does the app install as 64-bit if the app supports it? 使用NDK r16b为64位Android构建OpenSSL 1.0.2n对bsd_signal的未定义引用 - Building OpenSSL 1.0.2n for 64-bit Android with NDK r16b undefined reference to bsd_signal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM