Last active
January 15, 2016 11:06
-
-
Save weibeld/0b63549398a8ab00d4db to your computer and use it in GitHub Desktop.
Compile a C program for an Android ARM 32-bit device
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
#!/bin/bash | |
# | |
# Compile a C program for Nexus 6 (or other device with an ARM 32-bit processor) | |
# | |
# Requirements: | |
# - Android NDK | |
# | |
# Daniel Weibel <[email protected]> January 2016 | |
#------------------------------------------------------------------------------# | |
# Compiler for ARM 32-bit target platform (adapt if necessary) | |
compile() { | |
~/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc $@ | |
} | |
usage() { | |
cat <<EOF | |
Wrapper around ARM 32-bit compiler (see usage below). | |
The following options are set by this script: | |
--sysroot | |
-fPIE | |
-pie | |
Usage: | |
$(basename "$0") [options] file... | |
---- | |
EOF | |
compile --help | |
} | |
[[ "$1" = -h || "$1" = --help ]] && { usage; exit; } | |
# C headers and libraries for target platform (adapt if necessary) | |
sysroot=~/android-ndk-r10e/platforms/android-21/arch-arm | |
# Execute (-pie: create a position independent executable --> required for | |
# newer Android versions) | |
compile \ | |
--sysroot="$sysroot" \ | |
-fPIE \ | |
-pie \ | |
$@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment