Android.mk 语法参考文件

本文详细介绍了在Android.mk中如何编译出多个.so文件,包括使用CLEAR_VARS变量进行多库编译的方法及all-subdir-makefiles函数的应用。提供了一个简单的范例,并解释了相关变量的作用。

下载NDK,最好使用r8版本以后的,因为之后的版本不需要再去配置cygwin了。

解压,配置NDK的路径,windows中配置环境变量即可。

参考文件:~\docs\ANDROID-MK.html

详细阅读说明文档。

 

简单范例如下:

---------- cut here ------------------ 

  LOCAL_PATH := $(call my-dir) 

  include $(CLEAR_VARS)  

 LOCAL_MODULE    := hello-jni 

  LOCAL_SRC_FILES := hello-jni.c 

  include $(BUILD_SHARED_LIBRARY)  

 ---------- cut here ------------------

问题:

1. 如何考虑在Android.mk中编译出多个so文件?

include $(CLEAR_VARS)

The CLEAR_VARS variable is provided by the build system and points to aspecial GNU Makefile that will clear many LOCAL_XXX variables for you(e.g. LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES, etc...),with the exception of LOCAL_PATH. This is needed because all buildcontrol files are parsed in a single GNU Make execution context whereall variables are global.

想编译出多个库,在一个执行结束后,调用include $(CLEAR_VARS),再写新的需要编译的源文件以及定义目标文件,应该就可以实现了。

 

也可以通过以下方式实现

all-subdir-makefiles   

 Returns a list of Android.mk located in all sub-directories of    the current 'my-dir' path. For example, consider the following    hierarchy:       

sources/foo/Android.mk       

sources/foo/lib1/Android.mk      

sources/foo/lib2/Android.mk   

If sources/foo/Android.mk contains the single line:        include $(call all-subdir-makefiles)    Then it will include automatically sources/foo/lib1/Android.mk and    sources/foo/lib2/Android.mk    This function can be used to provide deep-nested source directory    hierarchies to the build system. Note that by default, the NDK    will only look for files in sources/*/Android.mk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值