可以以
http://blog.csdn.net/bupt073114/article/details/43114223 示例
虚拟机——D:\Genymobile-virtual-devices\
Google Nexus 9 - 5.1.0 - API 22 - 2048x1536
ndk-build——E:\Andriod\
android-ndk-r10d
adb.exe——E:\Andriod\
android-sdk_r24.3.3-windows\android-sdk-windows\platform-tools
F:\project\android\test\socket\jni 中包含文件:Android.mk, cli.c,serv.c
Android.mk 文件 内容如下:
#------------------------------------------------------
#error: only position independent executables (PIE) are supported.
#PIE这个安全机制从4.1引入,但是Android L之前的系统版本并不会去检验可执行文件是否基于PIE编译出的。
#因此不会报错。但是Android L已经开启验证,如果调用的可执行文件不是基于PIE方式编译的,则无法运行。
# F:\project\android\test\socket\jni
# jni> ndk-build
# jni> ndk-build -B APP_ABI=x86
adb pull <remote> <local>
adb push <local> <remote>
# F:\project\android\test\socket\libs
# adb push cli /data/data/
# adb push serv /data/data/
# adb shell
# cd /data/data/
# chmod 777 serv
# chmod 777 cli
# ./serv
# ./cli
#------------------------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -O3 -fvisibility=hidden
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
LOCAL_MODULE := serv
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := \
serv.c \
LOCAL_LDLIBS := -lz -llog -L$(SYSROOT)/usr/lib
cmd-strip = $(TOOLCHAIN_PREFIX)strip $1
include $(BUILD_EXECUTABLE)
#include $(BUILD_SHARED_LIBRARY)
#LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -O3 -fvisibility=hidden
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
LOCAL_MODULE := cli
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := \
cli.c \
LOCAL_LDLIBS := -lz -llog -L$(SYSROOT)/usr/lib
cmd-strip = $(TOOLCHAIN_PREFIX)strip $1
include $(BUILD_EXECUTABLE)
#include $(BUILD_SHARED_LIBRARY)
阅读(1582) | 评论(0) | 转发(0) |