demo.c
#include <stdio.h> int main(int argc, char *argv[]) { printf("www.chinapyg.com!\n"); return 0; }
Android.mk
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := demo LOCAL_SRC_FILES := ../demo.c LOCAL_ARM_MODE := arm LOCAL_CFLAGS := -g LOCAL_CFLAGS += -pie -fPIE LOCAL_LDFLAGS += -pie -fPIE include $(BUILD_EXECUTABLE)
Application.mk
APP_OPTIM := release APP_PLATFORM := android-14 APP_ABI := armeabi-v7a
NDK编译:
C:\Users\piao\Downloads\adbi\demo\jni λ ndk-build.cmd [armeabi-v7a] Compile arm : demo <= demo.c [armeabi-v7a] Executable : demo [armeabi-v7a] Install : demo => libs/armeabi-v7a/demo
经过测试~~
此警告只会在5.0以上系统出现:
root@ido:/data/local/tmp # ./demo WARNING: linker: ./demo: unused DT entry: type 0x6ffffffe arg 0x41c WARNING: linker: ./demo: unused DT entry: type 0x6fffffff arg 0x1 www.chinapyg.com!
解决方法:https://github.com/kost/android-elf-cleaner
在Ubuntu16.04编译后:
piao@piaopiao:~/Desktop/android-elf-cleaner$ make g++ -std=c++14 -Wall -Wextra -pedantic -Werror android-elf-cleaner.cpp -o android-elf-cleaner
然后执行:
piao@piaopiao:~/Desktop/android-elf-cleaner$ ./android-elf-cleaner demo ./android-elf-cleaner: Removing the DT_VERNEEDED dynamic section entry from 'demo' ./android-elf-cleaner: Removing the DT_VERNEEDNUM dynamic section entry from 'demo' piao@piaopiao:~/Desktop/android-elf-cleaner$
再次push到手机里面运行:
root@ido:/data/local/tmp # ./demo www.chinapyg.com!
如果哪位大神有更加优雅的办法解决(比如添加什么编译参数之类的)还请告知!!
参考文档:https://stackoverflow.com/questions/33206409/unused-dt-entry-type-0x1d-arg/41900551
已有1位网友发表了看法:
发表评论