手动调用NDK编译HelloWorld

首先,你得有NDK(木有的自行搜索)

/home/xxxx/tools/android-ndk-r12b

准备好你的HelloWorld程序源码:

#include<stdio.h>
int main(void) {
  printf("Hello World!
");
  return 0;
}

编译之:

~/tools/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc  -o hello hello.c -pie -fPIE -I/home/xxxx/tools/android-ndk-r12b/platforms/android-24/arch-arm64/usr/include -L/home/xxxx/tools/android-ndk-r12b/platforms/android-24/arch-arm64/usr/lib --sysroot=/home/xxxx/tools/android-ndk-r12b/platforms/android-24/arch-arm64/usr/

不加pie fPIE编译项在Android L之后版本会报错:error: only position independent executables (PIE) are supported.

其他参数自行理解,Over。

出错解决链接:http://blog.csdn.net/hxdanya/article/details/39371759

备注:aHR0cCUzQS8vd3d3LmNuYmxvZ3MuY29tL3poaGQv

原文地址:https://www.cnblogs.com/zhhd/p/5755867.html