标签:android compiler android ndk shell
mk_app jni main.c Android.mkAndroid.mk内容十分满简单:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= main_exec LOCAL_SRC_FILES := main.c include $(BUILD_EXECUTABLE)命令下,cd到jni的上一级目录,然后执行ndk-build命令:
E:\GitHub\ndk_tutorial\android_build_c_exec\mk_ap>ndk-build [armeabi] Compile thumb : main_exec <= main.c [armeabi] Executable : main_exec [armeabi] Install : main_exec => libs/armeabi/main_exec
gcc_app main.c命令行,cd到gcc_app目录下,然后执行下面命令:
D:\android-ndk-r9b-windows-x86\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gcc.exe --sysroot=D:\android-ndk-r9b-windows-x86\platforms\android-13\arch-arm -o main_exec main.c
E:\GitHub\ndk_tutorial\android_build_c_exec\gcc_app>adb push main_exec /sdcard/ 1528 KB/s (6260 bytes in 0.004s) E:\GitHub\ndk_tutorial\android_build_c_exec\gcc_app>adb shell shell@mako:/ $ cp /sdcard/main_exec /data/local/ cp /sdcard/main_exec /data/local/ cp: /data/local/main_exec: Permission denied 1|shell@mako:/ $ cp /sdcard/main_exec /data/local/tmp cp /sdcard/main_exec /data/local/tmp shell@mako:/ $ cd /data/local/ cd /data/local/ shell@mako:/data/local $ cd tmp cd tmp shell@mako:/data/local/tmp $ ls -l main_exec ls -l main_exec -rwxr-x--x shell shell 6260 2014-06-06 16:30 main_exec shell@mako:/data/local/tmp $ chmod 751 main_exec chmod 751 main_exec shell@mako:/data/local/tmp $ ./main_exec ./main_exec hello world通过adb push到sdcard上,然后进入shell模式,从sdcard复制到/data/local/tmp 下(注意我的n4手机上/data/local下权限不够,进入tmp可以)。
Android上通过gcc编译普通的C程序,布布扣,bubuko.com
标签:android compiler android ndk shell
原文地址:http://blog.csdn.net/ryfdizuo/article/details/28891649