How to build host static library with Android NDK?

旧城冷巷雨未停 提交于 2021-02-11 06:34:37

问题


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.

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?


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/29912804/how-to-build-host-static-library-with-android-ndk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!