C语言编译成可执行文件的模板,并放到虚拟机中运行。
1,mkdir helloworld;mkdir helloworld/jni;mkdir helloworld/libs
2,helloworld.c:
#include <stdio.h>
int main()
{
printf("hello sno_guo@163.com\n");
return 0;
}
3,Android.mk
LOCAL_PATH :=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
helloworld.c
LOCAL_MODULE :=helloworld
#LOCAL_C_INCLUDES:=
#LOCAL_STATIC_LIBRARIES:=
# LOCAL_SHARED_LIBRARIES:=
include $(BUILD_EXECUTABLE)
4,编译:ndk-build
编译后的结果:
$ndk-build
Compile thumb : helloworld <= helloworld.c
Executable : helloworld
Install : helloworld => libs/armeabi/helloworld
5,放到虚拟机中:
./adb push helloworld /data
159 KB/s (8584 bytes in 0.052s)
6,进入虚拟机
./adb shell
#cd /data
#./helloworld
#hello sno_guo@163.com //输出的结果