如何使用Android NDK构建主机静态库? [英] How to build host static library with Android NDK?

查看:156
本文介绍了如何使用Android NDK构建主机静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从来源.由于显示了文件 Android.mk ,因此我正在运行 ndk-build 工具进行构建.但不幸的是,我遇到以下错误:

I'm trying to build android adb tool from the sources. Since file Android.mk is presented i'm running ndk-build tool to build it. But unfortunately i'm having following errors:

/Users/user/Documents/dev/tmp/adb/jni/Android.mk:95: /softdev/android-ndk-r10c/build/core/build-host-static-library.mk: No such file or directory
/Users/user/Documents/dev/tmp/adb/jni/Android.mk:183: /softdev/android-ndk-r10c/build/core/build-host-executable.mk: No such file or directory
Android NDK: Trying to define local module 'adbd' in /Users/user/Documents/dev/tmp/adb/jni/Android.mk.    
Android NDK: But this module was already defined by /Users/user/Documents/dev/tmp/adb/jni/Android.mk.    
/softdev/android-ndk-r10c/build/core/build-module.mk:34: *** Android NDK: Aborting.    .  Stop.

由于某些原因,我已经检查了文件( build-host-*-*.mk )是否缺失.我在某人的 git repo 中找到了它们,但是它用于Windows.将 build-host-*-* .. mk 复制到我的本地ndk文件夹后,我遇到了另一个错误:

I've checked files (build-host-*-*.mk) are absent for some reason. I've found them in someone's git repo, but it's for windows. After copying build-host-*-*.mk to my local ndk folder i'm getting another errors:

Android NDK: /Users/user/Documents/dev/tmp/adb/jni/Android.mk:adb: Unknown LOCAL_MODULE_CLASS value: HOST_STATIC_LIBRARY    
/softdev/android-ndk-r10c/build/core/build-module.mk:29: *** Android NDK: Aborting    .  Stop.

因此,仅复制该文件似乎还不够.我该如何建造它?

So it seems that just copying that files is not enough. How can i make it built?

推荐答案

adb是一个宿主工具(可在您的PC上运行,而不是在Android设备上运行),并且NDK不支持构建宿主可执行文件.它确实提供了一些存根,但从未完全实现该功能.

adb is a host tool (which runs on your PC rather than on the Android device), and NDK has no support for building host executables. It does provide some stubs but the feature was never fully implemented.

您链接到的git repo不是官方的NDK r7b,而是添加了主机目标支持的修补版本.这不仅包括单个文件,还包括完整的diff

The git repo you are linking to is not the official NDK r7b but a patched version with host target support added. This includes a bit more than just a single file – see the full diff here.

您将需要将此补丁程序(或将所有已修改的脚本复制)应用于本地NDK设置.如果您正在运行R7b以外的NDK版本,则可能需要进行一些其他修改.

You will need to apply this patch (or copy all the scripts which were modified) to your local NDK setup. If you are running an NDK version other than r7b, you may have to make some additional modifications.

另请参阅我的问题,而我基本上遇到了同样的问题.

See also my question, in which I basically ran into the same issue.

这篇关于如何使用Android NDK构建主机静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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