Android.mk#include <stdio.h> int flag = 1; int count = 0; int main() { char* str = "abcdef"; while(flag) { printf("Target is running:%d\n", count); count++; sleep(3); } return 0; }
代码很简单,就是一个循环打印语句。值得注意的是Android.mk,根据需要修改LOCAL_XXX的名字就可以了,如果有多个文件,添加到SRC_FILES后面就可以了LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := target LOCAL_SRC_FILES := target.c include $(BUILD_EXECUTABLE)
"Compile thumb : target <= target.c Executable : target Install : target => libs/armeabi/target
需要注意的地方是android下面busybox的chmod u+x target不能工作,只能用751这种数字方式来设置程序的可运行。root@android:/data/local/tmp # ./target ./target Target is running:0 Target is running:1 Target is running:2 Target is running:3 Target is running:4 Target is running:5
希望你好运,能够运行一个helloword的ndk程序
转载:http://blog.163.com/tod_zhang/blog/static/10255221420139198629861/