简体   繁体   English

如何使用Android NDK构建主机静态库?

[英]How to build host static library with Android NDK?

I'm trying to build android adb tool from the sources . 我正在尝试从源代码构建android adb工具。 Since file Android.mk is presented i'm running ndk-build tool to build it. 由于文件Android.mk出现了,所以我正在运行ndk-build工具来构建它。 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.

I've checked files ( build-host-*-*.mk ) are absent for some reason. 由于某些原因,我检查了文件( build-host-*-*.mk )的缺失。 I've found them in someone's git repo , but it's for windows. 我已经在某人的git repo中找到了它们,但这是用于Windows的。 After copying build-host-*-*.mk to my local ndk folder i'm getting another errors: build-host-*-*.mk复制到本地ndk文件夹后,出现另一个错误:

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 is a host tool (which runs on your PC rather than on the Android device), and NDK has no support for building host executables. adb是一个主机工具(在您的PC上而不是在Android设备上运行),并且NDK不支持构建主机可执行文件。 It does provide some stubs but the feature was never fully implemented. 它确实提供了一些存根,但从未完全实现该功能。

The git repo you are linking to is not the official NDK r7b but a patched version with host target support added. 您链接的git repo不是官方的NDK r7b,而是添加了主机目标支持的修补版本。 This includes a bit more than just a single file – see the full diff here . 这不仅包括单个文件,还包括其他内容-请在此处查看完整的diff。

You will need to apply this patch (or copy all the scripts which were modified) to your local NDK setup. 您将需要将此补丁应用(或将所有已修改的脚本复制)到本地NDK设置。 If you are running an NDK version other than r7b, you may have to make some additional modifications. 如果您正在运行R7b以外的NDK版本,则可能需要进行一些其他修改。

See also my question , in which I basically ran into the same issue. 另请参阅我的问题 ,在该问题中,我基本上遇到了同一问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM