Last active
June 21, 2024 15:29
-
-
Save slavc/34d4acd506ea4a7b58079cb0772870d0 to your computer and use it in GitHub Desktop.
How to install an Android toolchain
This file contains 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
These instructions describe how to install an Android toolchain capable of compiling standalone C/C++ programs for an Android device. | |
1. Download Android NDK from https://developer.android.com/ndk/downloads/index.html and unpack it somewhere. | |
2. Run the included script to install a standalone toolchain: | |
mkdir $HOME/opt | |
$NDK/build/tools/make-standalone-toolchain.sh --arch=arm --install-dir=$HOME/opt/android_toolchain | |
3. Create a test program and compile it: | |
cat > hello.c << EOF | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
printf("Hello, world!\n"); | |
return 0; | |
} | |
EOF | |
$HOME/opt/android_toolchain/bin/arm-linux-androideabi-gcc -fPIC -pic -o hello hello.c | |
4. Upload the compiled program to the device and see if it works: | |
adb push hello /cache/hello | |
adb shell | |
root@GT-I9100:/ # /cache/hello | |
WARNING: linker: /cache/hello: unused DT entry: type 0x6ffffffe arg 0x2e0 | |
WARNING: linker: /cache/hello: unused DT entry: type 0x6fffffff arg 0x1 | |
Hello, world! | |
root@GT-I9100:/ # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment