Created
July 19, 2017 23:10
-
-
Save qeedquan/e98e532beee55fb34add495e3cf00a1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://stackoverflow.com/questions/10798357/want-to-compile-native-android-binary-i-can-run-in-terminal-on-the-phone | |
/* | |
# create tool-chain - one line | |
# New method in ndk 12. | |
$NDK/build/tools/make_standalone_toolchain.py --arch arm --install-dir=/tmp/my-android-toolchain | |
# Old method. | |
#$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=/tmp/my-android-toolchain | |
# add to terminal PATH variable | |
export PATH=/tmp/my-android-toolchain/bin:$PATH | |
# make alias CC be the new gcc binary | |
export CC=arm-linux-androideabi-gcc | |
# compile your C code(I tried hello world) | |
$CC -o foo test-ndk.c | |
# push binary to phone | |
adb push test-ndk /data/local/tmp | |
# execute binary | |
adb shell | |
$ /data/local/tmp/test-ndk | |
*/ | |
#include <stdio.h> | |
int | |
main(void) | |
{ | |
printf("test-ndk works\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
another tutorial here: https://explog.in/notes/droidbinary.html