I'm writing a bash script that uses Netcat to serve framebuffer over network connection, but first I need to compile it to native executable. I even got this script to work on a Ubuntu machine, where netcat is installed by 开发者_JAVA百科default.
I found this https://github.com/android/platform_external_netcat but have no experience in NDK at all. This obviously doesn't use JNI or Java at all so default approach for making Android applications won't get me anywhere.
So the question is. How do I get an executable file from this source code?
If anybody else wants to know, this is from the NDK documentation:
SYSROOT=$NDK/platforms/android-<level>/arch-<arch>/
export CC="$NDK/toolchains/<name>/prebuilt/<system>/bin/<prefix>gcc --sysroot=$SYSROOT"
$CC -o foo.o -c foo.c
More specifically, for the netcat from https://github.com/android/platform_external_netcat
SYSROOT=$NDK/platforms/android-19/arch-arm
CC=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT
$CC -DANDROID -c -o atomicio.o atomicio.c
$CC -DANDROID -c -o netcat.o netcat.c
$CC -o netcat atomicio.o netcat.o
Replace the paths from SYSROOT and CC as appropriate.
Look in the Android sdk under docs/STANDALONE-TOOLCHAIN.html it describes how to use the ndk as standalone compiler which can produce arm binaries.
精彩评论