Android的NDK build-host-executable.mk:没有这样的文件或目录 [英] Android NDK build-host-executable.mk: No such file or directory

查看:1298
本文介绍了Android的NDK build-host-executable.mk:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

短的问题:

我试图建立一个具有JNI依赖,使用Eclipse ADT和NDK r10e(当前版本)的应用程序。 JNI的依赖(显然)建立了一个二进制编译主机上,运行使用 build-host-executable.mk 从NDK。然而,该脚本似乎已经在最近的NDK版本被删除。我该怎么办?

I'm trying to build an app that has a JNI dependency, using Eclipse ADT and NDK r10e (the current version). The JNI dependency (apparently) builds a binary to run on the build host, using build-host-executable.mk from the NDK. However, that script seems to have been removed in recent NDK versions. What do I do?

长的问题:

JNI的依赖是从AOSP,附带平台/外部/ SREC 一个 Android.mk 文件(实际上,其中几个)。

The JNI dependency is platform/external/srec from AOSP, which comes with an Android.mk file (actually, several of them).

我已经设置Eclipse按照说明这里打造本地部分,并复制JNI的code树到我的应用程序的源代码树的 JNI 目录。此外,我不得不修改 JNI / Android.mk ,添加以下行:

I have set up Eclipse to build the native parts according to the instructions here, and copied the JNI code tree into the jni directory of my app's source tree. Additionally, I had to edit jni/Android.mk, adding the following line:

export TARGET_BUILD_TYPE := debug

其中,据我所知,将由AOSP工具链进行设置,但在Eclipse构建时未设置。

which, as I understand it, would be set by the AOSP toolchain but is not set when building from Eclipse.

不过,我得到以下错误:

However, I get the following error:

android-ndk-r10e/build/core/build-host-executable.mk: No such file or directory

这是一条线在我的 Android.mk 文件之一引起的:

This is caused by a line in one of my Android.mk files:

include $(BUILD_HOST_EXECUTABLE)

NDK的定义 BUILD_HOST_EXECUTABLE 建立/核心/ build-all.mk

BUILD_HOST_EXECUTABLE     := $(BUILD_SYSTEM)/build-host-executable.mk

然而, build_host_executable.mk 是从建立/芯目录中没有(因此是其他建立主机 - * MK 周边线路声明脚本)

However, build_host_executable.mk is absent from the build/core directory (and so are the other build-host-*.mk scripts declared in the surrounding lines).

张望了一下谷歌搜索,我发现这个剧本似乎已经在早期的NDK版本present(至少达到NDK R7 R7B),但似乎是从缺席更高版本(可能是因为r10b)。 JNI的LIB曾通过(现已放弃)的语音拨号应用程序。它曾在2014年12月最后一次提交,但最后真正code改变可能已经在2014年6月AOSP已经停止构建它到2015年这与NDK版本历史相比6月,可能永远不会被建成对NDK版本高于r9d或者R10。

Googling around a bit, I find that this script seems to have been present in earlier NDK versions (up to at least NDK r7 r7b) but seems to be absent from later versions (possibly since r10b). The JNI lib was used by the (now abandoned) Voice Dial app. It had its last commit in December 2014, though the last real code change might have been in June 2014. AOSP had stopped building it by June 2015. Comparing this with the NDK release history, it might never have been built against NDK versions later than r9d or maybe r10.

NDK的R7B我发现似乎是一个修补版本到目标主机添加支持,也见 https://github.com/flyskywhy/android-ndk-host 。看起来这种支持NDK中,计划和一些存根添加,但它从来没有完全实现。这给了我要么建立东道国的东西与本地工具链,或修补NDK r10e添加主机目标支持的选择。

The NDK r7b I found appears to be a patched version to which host target support added, see also https://github.com/flyskywhy/android-ndk-host. Looks like support for this was planned in NDK and some stubs added, but it was never fully implemented. That gives me the choice of either building the host stuff with the local toolchain, or patching NDK r10e to add host target support.

在另一方面,这个包已经一段时间了AOSP的一部分(包括了CyanogenMod,直到奇巧和棒棒堂放弃了它),因此AOSP工具链必须有能力建设好它。任何指针到该工具链?也许这是可以从AOSP工具链中提取相关部件并将它们添加到包。

On the other hand, this package has been part of AOSP for a while (Cyanogenmod included it until KitKat and dropped it in Lollipop), therefore the AOSP toolchain must have been capable of building it. Any pointers to that toolchain? Maybe it's possible to extract the relevant parts from the AOSP toolchain and add them to the package.

推荐答案

有问题的JNI依赖从AOSP code树服用。由AOSP使用的工具链是从NDK不同,虽然两者都围绕一组GNU内置使宏。对于格式 Android.mk (他们的makefile当量)是在两者之间故意相似,因此,在很多情况下,一个项目可以与任一工具链构建的。

The JNI dependency in question is taken from the AOSP code tree. The toolchain used by AOSP is different from NDK, though both are built around a set of GNU make macros. The format for Android.mk (their makefile equivalent) is intentionally similar between both, so that in many cases a project can be built with either toolchain.

一种情况下,这将不起作用是主机的目标,即建设二进制文件旨在构建主机上,而不是在Android设备上运行(可执行文件或库)。该工具链AOSP有这样的支持,但NDK没有。令人困惑的是,在NDK确实有这个功能有些存根(包括 BUILD_HOST_EXECUTABLE 和类似的定义),但执行丢失。

One case for which this will not work is host targets, i.e. building binaries (executables or libraries) intended to run on the build host rather than on the Android device. The AOSP toolchain has this kind of support but the NDK doesn't. Confusingly, the NDK does have some stubs for that functionality (including definitions for BUILD_HOST_EXECUTABLE and similar) but the implementation is missing.

有三个选项。要知道,你正在构建的包可能依赖于其他包从AOSP源$ C ​​$ C,你将需要建立为好。

There are three options. Be aware that the package you are building may depend on other packages from the AOSP source code, which you would need to build as well.


  • 构建使用AOSP工具链本地code(或主机的目标),如这个答案描述。这种方法是最有可能成功,因为这是该包装设计的工具链。它至少需要包含构建工具,这是在大小数千兆字节的包。你可以得到整个AOSP源$ C ​​$ C作为这里描述,这应该给你你需要的所有的依赖,但这会下载一些50千兆字节(!)的数据。

  • 有增加了对主机的目标这里支持NDK的修补版本(或只是make宏这里)。但是,它是基于现已过时的NDK R7B,而且其在去年的某个时候2012提交 - 你会用一个工具链是有点异国情调,不再进行维护工作。此外,你需要通过检查包手动确定你的依赖。

  • 沟的建设主机的目标并用常规的GNU工具链构建这些在 Android.mk 文件。该介绍,可以发现<一个href=\"https://saidsecurity.word$p$pss.com/2012/10/11/how-to-compile-android-native-$c$c-with-regular-makefile/\"相对=nofollow>此处。你可以修改更高级别的 Android.mk 来调用其他工具链主机的目标,这样你就可以自动完成整个构建。所有这一切都可能是大量的工作,如果 Android.mk 的内容是非常复杂的,但它是一个一次性的努力,在这之后你的code能增强与标准的工具链。如同previous方法,你需要手动确定你的依赖。需要哪些主机目标相关性可能会更容易,不过,如果它们是被移植到Android标准库,有可能是设计与GNU工具链构建的上游版本。

  • Build the native code (or the host targets) using the AOSP toolchain, as described in this answer. This approach is most likely to be successful, as this is the toolchain for which the package was designed. It requires at least the packages containing the build tools, which are several gigabytes in size. You can get the entire AOSP source code as described here, which should give you all the dependencies you need, but this will download some 50 gigabytes (!) of data.
  • There is a patched version of NDK which adds support for host targets here (or just the make macros here). However, it is based on the now-outdated NDK r7b and had its last commit sometime in 2012 – you'll be working with a toolchain that is somewhat exotic and no longer maintained. Also, you'll need to determine your dependencies manually by examining the package.
  • Ditch the Android.mk files that build the host targets and build these with a regular GNU toolchain. An introduction to that can be found here. You can amend a higher-level Android.mk to invoke the "other" toolchain for your host targets, so you can automate the whole build. All of this may be a lot of work if the Android.mk content is very complex, but it is a one-time effort, after which your code will build with standard toolchains. As with the previous approach, you'll need to determine your dependencies manually. Dependencies which are required for the host target may be easier, though, if they are standard libraries which were ported to Android, as there may be an upstream version designed to be built with the GNU toolchain.

这篇关于Android的NDK build-host-executable.mk:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆