android Alexa auto find downloaded ndk path - android

This is the setup-android-toolchin.sh file `
#!/bin/bash
set -e
THISDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source ${THISDIR}/common.sh
# Default external values
: ${NDK_PACKAGE:="android-ndk-r16b"}
: ${NDK_SHA1SUM:="42aa43aae89a50d1c66c3f9fdecd676936da6128"}
# Extra options
ANDROID_ABI=${1}
API_LEVEL=${2}
#
# Param checks
#
if [ -z ${ANDROID_TOOLCHAIN} ]; then
error "ANDROID_TOOLCHAIN is not set"
fi
if [ -z ${ANDROID_ABI} ] || [ -z ${API_LEVEL} ]; then
error "Please specify ABI/API"
fi
# Android toolchain path
ANDROID_NDK="${ANDROID_TOOLCHAIN}/ndk"
ANDROID_SDK="${ANDROID_TOOLCHAIN}/sdk"
# Standard Android path
ANDROID_NDK_HOME="${ANDROID_NDK}/ndk-bundle/${NDK_PACKAGE}"
# OS detection
if [ $(uname) = "Darwin" ]; then
HOST="darwin"
else
HOST="linux"
fi
install() {
filename=${1}
checksum=${2}
dest=${3}
tmpdir=${ANDROID_TOOLCHAIN}
tmpfile=${tmpdir}/${filename}
if [ -e ${tmpfile} ] && [ ! "$(sha1sum ${tmpfile})" = "${checksum}" ]; then
warn "SHA1 checksum is wrong, re-download NDK package..."
rm ${tmpfile}
fi
if [ ! -e ${dest} ]; then
note "Downloading file ${filename}"
wget --no-check-certificate https://dl.google.com/android/repository/${filename} -P ${tmpdir}
sha1sum ${tmpfile}
fi
mkdir -p ${dest}
pushd ${dest}
unzip -q ${tmpfile}
popd
}
generate_toolchain() {
case ${ANDROID_ABI} in
x86)
ARCH="x86"
;;
x86_64)
ARCH="x86_64"
;;
armeabi-v7a)
ARCH="arm"
;;
arm64-v8a)
ARCH="arm64"
;;
*)
error "Unknown ABI: ${ANDROID_ABI}"
esac
TOOLCHAIN="${ANDROID_NDK}/toolchains/${NDK_PACKAGE}/toolchain-${ANDROID_ABI}/android-${API_LEVEL}"
if [ ! -d ${TOOLCHAIN} ]; then
note "Generating Standalone Toolchain..."
${ANDROID_NDK}/ndk-bundle/${NDK_PACKAGE}/build/tools/make_standalone_toolchain.py \
--arch="${ARCH}" \
--api="${API_LEVEL}" \
--stl="libc++" \
--force \
--install-dir="${TOOLCHAIN}"
fi
}
note "Checking Android toolchain installation (${ANDROID_ABI}/${API_LEVEL})..."
if [ ! -d ${ANDROID_NDK_HOME} ]; then
note "Installing NDK (${NDK_PACKAGE})..."
install ${NDK_PACKAGE}-${HOST}-x86_64.zip ${NDK_SHA1SUM} ${ANDROID_NDK}/ndk-bundle
fi
if [ ! -d ${ANDROID_SDK} ]; then
note "Installing SDK Tools..."
install sdk-tools-${HOST}-3859397.zip "7eab0ada7ff28487e1b340cc3d866e70bcb4286e" ${ANDROID_SDK}
fi
generate_toolchain
`. After running the script it downloaded the NDK in /workdir/android. I am not getting where it has downloaded the NDK as I am not able to find it through finder(Mac OS High Sierra). Can anyone tell the path to where I can find the NDK. Using search option is not helping me.

Related

valgrind for Android devices (Crystax). configure: error: C compiler cannot create executables

Using and adapting the script(https://gist.github.com/smits/27060b310546ca6f76568f24838118c3) I get and error " C compiler cannot create executables":
#!/usr/bin/env bash
#set -x
function extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xvjf "$1" ;;
*.tgz) tar xvzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "$1 cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
VALGRIND_VERSION="3.15.0"
VALGRIND_EXTENSION=".tar.bz2"
VALGRIND_DIRECTORY="valgrind-${VALGRIND_VERSION}"
VALGRIND_TARBALL="valgrind-${VALGRIND_VERSION}${VALGRIND_EXTENSION}"
# Only download Valgrind tarball again if not already downloaded
if [[ ! -f "${VALGRIND_TARBALL}" ]]; then
wget -v -nc "https://sourceware.org/pub/valgrind/${VALGRIND_TARBALL}"
fi
# Only extract Valgrind tarball again if not already extracted
if [[ ! -d "$VALGRIND_DIRECTORY" ]]; then
extract "$VALGRIND_TARBALL"
fi
# Ensure ANDROID_NDK is set
#if [[ ! -z "$ANDROID_NDK" ]]; then
export ANDROID_NDK="/home/userhome/src/crystax-ndk-10.3.1"
#fi
# Ensure ANDOID_SDK_HOME is set
#if [[ ! -z "$ANDROID_SDK" ]]; then
#export ANDROID_SDK="/opt/android-sdk-linux/"
#fi
if [[ ! -d "$VALGRIND_DIRECTORY" ]];
then
echo "Problem with extracting Valgrind from $VALGRIND_TARBALL into $VALGRIND_DIRECTORY!!!"
exit -1
fi
# Move to extracted directory
cd "$VALGRIND_DIRECTORY"
# ARM Toolchain
export PATH=$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin:$PATH
ARCH_ABI="arm-linux-androideabi-6"
export AR="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar"
export LD="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld"
export CC="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
export CXX="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
export RANLIB="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib"
export AS="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as"
export CPP="$ANDROID_NDK/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp"
echo $ANDROID_NDK
echo $AR
echo $LD
echo $CC
echo $CXX
[[ ! -d "$ANDROID_NDK" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure ANDROID_NDK is defined also" && exit -1
# Configure build
export HWKIND="generic"
ANDROID_PLATFORM=android-21
export CPPFLAGS="--sysroot=$ANDROID_NDK/platforms/${ANDROID_PLATFORM}/arch-arm -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_NDK/platforms/${ANDROID_PLATFORM}/arch-arm"
# BUG: For some reason file command is unable to detect if the file does not exist with ! -f , it says it doesn't exist even when it does!!!
BUILD=true
if [[ "${VALGRIND_DIRECTORY}/Inst/data/local/Inst/bin/valgrind" = *"No such file or directory"* ]]; then
BUILD=true
fi
if [[ "$BUILD" = true ]];
then
./configure --prefix="/data/local/Inst" \
--host="armv7-unknown-linux" \
--target="armv7-unknown-linux" \
--with-tmpdir="/sdcard"
[[ $? -ne 0 ]] && echo "Can't configure!" && exit -1
# Determine the number of jobs (commands) to be run simultaneously by GNU Make
NO_CPU_CORES=$(grep -c ^processor /proc/cpuinfo)
if [ $NO_CPU_CORES -le 8 ]; then
JOBS=$(($NO_CPU_CORES+1))
else
JOBS=${NO_CPU_CORES}
fi
# Compile Valgrind
make -j "${JOBS}"
[[ $? -ne 0 ]] && echo "Can't compile!" && exit -1
# Install Valgrind locally
make -j "${JOBS}" install DESTDIR="$(pwd)/Inst"
[[ $? -ne 0 ]] && echo "Can't install!" && exit -1
fi
# Push local Valgrind installtion to the phone
if [[ $(adb shell ls -ld /data/local/Inst/bin/valgrind) = *"No such file or directory"* ]];
then
adb root
adb remount
adb shell "[ ! -d /data/local/Inst ] && mkdir /data/local/Inst"
adb push Inst /
adb shell "ls -l /data/local/Inst"
# Ensure Valgrind on the phone is running
adb shell "/data/local/Inst/bin/valgrind --version"
# Add Valgrind executable to PATH (this might fail)
adb shell "export PATH=$PATH:/data/local/Inst/bin/"
fi
I got the following error ( C compiler cannot create executables):
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for armv7-unknown-linux-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether ln -s works... yes
checking for armv7-unknown-linux-gcc... /home/rubvacalz/src/crystax-ndk-10.3.1/toolchains/arm-linux-androideabi-6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... no
configure: error: in `/home/rubvacalz/src/valgrind-3.15.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
Can't configure!
And config.log says "error: cannot find -lcrystax":
configure:3723: checking whether the C compiler works
configure:3745: /home/rubvacalz/src/crystax-ndk-10.3.1/toolchains/arm-linux-androideabi-6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/home/rubvacalz/src/crystax-ndk-10.3.1/platforms/android-21/arch-arm --sysroot=/home/rubvacalz/src/crystax-ndk-10.3.1/platforms/android-21/arch-arm -DANDROID_HARDWARE_yellowstone conftest.c >&5
/home/rubvacalz/src/crystax-ndk-10.3.1/toolchains/arm-linux-androideabi-6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/6.1/../../../../arm-linux-androideabi/bin/ld: **error: cannot find -lcrystax**
collect2: error: ld returned 1 exit status
configure:3749: $? = 1
configure:3787: result: no
configure: failed program was:
I don't know if the following includes are required and I don't know if it is included in the script process.
-I/home/userhome/src/crystax-ndk-10.3.1/sources/crystax/include -I/home/userhome/src/crystax-ndk-10.3.1/platforms/android-21/arch-arm/usr/include -I/home/userhome/src/crystax-ndk-10.3.1/sources/cxx-stl/gnu-libstdc++/6/include -I/home/userhome/src/crystax-ndk-10.3.1/sources/cxx-stl/gnu-libstdc++/6/libs/armeabi-v7a/include -I/home/userhome/src/crystax-ndk-10.3.1/sources/cxx-stl/gnu-libstdc++/6/include/backward
I fix the problem. It just add in the script the lines:
export LDFLAGS="-L/home/userhome/src/crystax-ndk-10.3.1/sources/crystax/libs/armeabi-v7a/thumb"
export LIBS="-lcrystax"

Android NDK building tcpdump for different arch

Hi i am using this script but i can't find why the compiler cannot find the header libraries.
This is the script i'm using :
#!/bin/sh
SCRIPT_VERSION=1.0
BUILD_DIR=build
DEFAULT_TCPDUMP_VERSION=4.9.2
DEFAULT_LIBPCAP_VERSION=1.8.1
GIT_LIBPCAP="https://github.com/the-tcpdump-group/libpcap.git"
GIT_TCPDUMP="https://github.com/the-tcpdump-group/tcpdump.git"
BASE_URL="http://www.tcpdump.org/release"
ALL_ARCHS="arm arm64 mips mips64 x86 x86_64"
TOOLCHAINS="arm:arm-linux-androideabi-4.9:21
arm64:aarch64-linux-android-4.9:21
mips64:mips64el-linux-android-4.9:21
x86:x86-4.9:21
x86_64:x86_64-4.9:21"
ARCH_TRANSLATIONS="arm:arm-linux
arm64:aarch64-linux
mips:mipsel-linux
mips64:mips64el-linux
x86:x86
x86_64:x86_64"
BASE_CFLAGS="-O2 -fPIC -fPIE"
BASE_LDFLAGS=""
EXTRA_CFLAGS_arm="-march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=neon"
EXTRA_LDFLAGS_arm="-march=armv7-a -Wl,--fix-cortex-a8"
absolute_path() {
local ABS_PATH=$(cd "$1"; pwd)
echo $ABS_PATH
}
usage() {
PROGRAM=`basename $1`
echo "Usage: $PROGRAM [OPTIONS]"
echo "Version: ${SCRIPT_VERSION}"
echo "Automatically download and build tcpdump for Android devices"
echo "Also valid for Lollipop and Marshmallow"
echo ""
echo "OPTIONS:"
echo "-h Show this help"
echo "-a=ARCHS Space separated architectures to build or all. Default: all"
echo " Valid architectures: ${ALL_ARCHS}"
echo "-n=NDK_PATH Path of the Android NDK root"
echo " Default: Value of the NDK environment variable"
echo "-b=BUILD_DIR Destination of the compiled tcpdump. Default: build"
echo "-s Don't strip the final executable"
echo "-j=NPROCS Number of simultaneous jobs when compiling"
echo " Default: Number of cores of the machine"
echo "-t=TCPDUMP_VER Version of tcpdump or \"master\" for the latest revision in the repository"
echo " Default: ${DEFAULT_TCPDUMP_VERSION}"
echo "-l=LIBPCAP_VER Version of libpcap or \"master\" for the latest revision in the repository"
echo " Default: ${DEFAULT_LIBPCAP_VERSION}"
echo "-u=TCPDUMP_DIR Don't download tcpdump. Use the one in the specified directory"
echo "-m=LIBPCAP_DIR Don't download libpcap. Use the one in the specified directory"
echo
}
check_requirements() {
if [ ! -f "${NDK}/ndk-build" ]; then
echo "ERROR: Can't find the NDK directory"
exit 2
fi
flex -V > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: flex not found"
exit 2
fi
bison -V > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: bison not found"
exit 2
fi
if [ "${VERSION_LIBPCAP}" = "master" -o "${VERSION_TCPDUMP}" = "master" ]; then
git --version > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: git not found"
exit 2
fi
fi
if [ "${VERSION_LIBPCAP}" != "master" -o "${VERSION_TCPDUMP}" != "master" ]; then
wget -V > /dev/null 2>&1
if [ $? -eq 0 ]; then
DOWNLOADER=wget
else
curl -V > /dev/null 2>&1
if [ $? -eq 0 ]; then
DOWNLOADER=curl
else
echo "ERROR: wget or curl not found"
exit 2
fi
fi
fi
}
download_file() {
local URL="$1"
if [ "${DOWNLOADER}" = "wget" ]; then
wget "${URL}"
elif [ "${DOWNLOADER}" = "curl" ]; then
curl -O "${URL}"
fi
if [ $? -ne 0 ]; then
echo "ERROR: Can't download ${URL}"
exit 3
fi
}
download() {
local PROGRAM="$1"
local VERSION="$2"
local GIT_URL="$3"
if [ "${VERSION}" = "master" ]; then
git clone "${GIT_URL}" "${PROGRAM}"
if [ $? -ne 0 ]; then
echo "ERROR: Can't download ${PROGRAM} repository from ${GIT_LIBPCAP}"
exit 3
fi
absolute_path "${PROGRAM}"
else
# Download and decompress from their web
DIR="${PROGRAM}-${VERSION}"
FILE="${DIR}.tar.gz"
download_file "${BASE_URL}/${FILE}"
tar xzf "${FILE}"
if [ $? -ne 0 ]; then
echo "ERROR: Can't extract ${FILE}"
exit 3
fi
absolute_path "${DIR}"
fi
}
check_archs() {
local IS_VALID=no
for arch in $1; do
IS_VALID=no
for valid_arch in ${ALL_ARCHS}; do
if [ "${valid_arch}" = "${arch}" ]; then
IS_VALID=yes
break
fi
done
if [ "${IS_VALID}" = "no" ]; then
echo "ERROR: The architecture ${arch} is not valid. Valid architectures are ${ALL_ARCHS}"
exit 3
fi
done
}
check_compiler_tools() {
local ARCH="$1"
local toolchain_dir=""
for toolchain_info in $TOOLCHAINS; do
t_arch="${toolchain_info%%:*}"
if [ "${t_arch}" = "${ARCH}" ]; then
toolchain_dir="${toolchain_info%:*}"
toolchain_dir="${toolchain_dir#*:}"
toolchain_platform=android-"${toolchain_info##*:}"
break
fi
done
if [ -z "${toolchain_dir}" ]; then
echo "ERROR: Can't find the toolchain directory for ${ARCH}"
exit 3
fi
local SYSROOT="${NDK}/platforms/${toolchain_platform}/arch-${ARCH}"
if [ ! -d "${SYSROOT}" ]; then
echo "ERROR: Can't find the platform directory ${toolchain_platform} for ${ARCH}"
exit 3
fi
CONFIG_ARCH=""
for arch_translation in $ARCH_TRANSLATIONS; do
t_arch="${arch_translation%%:*}"
if [ "${t_arch}" = "${ARCH}" ]; then
CONFIG_ARCH="${arch_translation##*:}"
break
fi
done
if [ -z "${CONFIG_ARCH}" ]; then
echo "ERROR: Can't determine the architecture for the \"configure\" script"
exit 3
fi
CC=""
COMPILERS=$(find "${NDK}/toolchains/${toolchain_dir}/prebuilt" -type f -name "*-gcc")
for compiler in $COMPILERS; do
printf "Testing ${compiler}... "
$compiler --version >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "OK"
CC="$compiler --sysroot=${SYSROOT}"
break
fi
echo "NOT VALID"
done
if [ -z "${CC}" ]; then
echo "ERROR: Can't find a valid compiler"
fi
RANLIB_TOOL=""
RANLIBS=$(find "${NDK}/toolchains/${toolchain_dir}/prebuilt" -type f -name "*-ranlib")
for ranlib in $RANLIBS; do
printf "Testing ${ranlib}... "
$ranlib --version >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "OK"
RANLIB_TOOL="${ranlib}"
break
fi
echo "NOT VALID"
done
if [ -z "${RANLIB_TOOL}" ]; then
echo "ERROR: Can't find a valid ranlib tool"
fi
if [ "${SHOULD_STRIP}" = "yes" ]; then
STRIP_TOOL=""
local STRIP_TOOLS=$(find "${NDK}/toolchains/${toolchain_dir}/prebuilt" -type f -name "*-strip")
for strip_tool in $STRIP_TOOLS; do
printf "Testing ${strip_tool}... "
$strip_tool --version >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "OK"
STRIP_TOOL="$strip_tool"
break
fi
echo "NOT VALID"
done
if [ -z "${STRIP_TOOL}" ]; then
echo "ERROR: Can't find a valid strip tool"
fi
fi
}
SHOULD_STRIP=yes
ARCHS="${ALL_ARCHS}"
TCPDUMP_VERSION="${DEFAULT_TCPDUMP_VERSION}"
LIBPCAP_VERSION="${DEFAULT_LIBPCAP_VERSION}"
NPROCS=`getconf _NPROCESSORS_ONLN`
DIR_LIBPCAP=""
DIR_TCPDUMP=""
while getopts "ha:n:b:sj:t:l:u:m:" arg; do
case "${arg}" in
a)
if [ "${OPTARG}" = "all" ]; then
ARCHS="${ALL_ARCHS}"
else
ARCHS="${OPTARG}"
check_archs "${ARCHS}"
fi
;;
t)
TCPDUMP_VERSION="${OPTARG}"
;;
l)
LIBPCAP_VERSION="${OPTARG}"
;;
n)
NDK="${OPTARG}"
;;
s)
SHOULD_STRIP=no
;;
b)
BUILD_DIR="${OPTARG}"
;;
j)
NPROCS="${OPTARG}"
;;
u)
DIR_TCPDUMP="${OPTARG}"
;;
m)
DIR_LIBPCAP="${OPTARG}"
;;
h)
usage $0
exit 0
;;
*)
usage $0
echo "ERROR: Invalid option"
exit 1
;;
esac
done
if [ ! -d "${BUILD_DIR}" ]; then
mkdir "${BUILD_DIR}" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: Can't create the directory ${BUILD_DIR}"
exit 3
fi
fi
BUILD_DIR=`absolute_path "${BUILD_DIR}"`
echo "Checking basic requirements..."
check_requirements
if [ -z "${DIR_LIBPCAP}" -o -z "${DIR_TCPDUMP}" ]; then
echo "Downloading source code..."
fi
if [ -z "${DIR_LIBPCAP}" ]; then
DIR_LIBPCAP=`download libpcap "${LIBPCAP_VERSION}" "${GIT_LIBPCAP}"`
fi
if [ -z "${DIR_TCPDUMP}" ]; then
DIR_TCPDUMP=`download tcpdump "${TCPDUMP_VERSION}" "${GIT_TCPDUMP}"`
fi
DIR_LIBPCAP=`absolute_path "${DIR_LIBPCAP}"`
DIR_TCPDUMP=`absolute_path "${DIR_TCPDUMP}"`
if [ ! -f "${DIR_LIBPCAP}/configure" ]; then
echo "ERROR: Can't find the \"configure\" libpcap script in ${DIR_LIBPCAP}"
exit 3
fi
if [ ! -f "${DIR_TCPDUMP}/configure" ]; then
echo "ERROR: Can't find the \"configure\" tcpdump script in ${DIR_TCPDUMP}"
exit 3
fi
GENERATED_FILES=""
for ARCH in ${ARCHS}; do
echo
echo "Checking compiler for ${ARCH}..."
check_compiler_tools "${ARCH}"
export CC
EXTRA_CFLAGS=$(eval echo \$EXTRA_CFLAGS_${ARCH})
export CFLAGS="${BASE_CFLAGS} ${EXTRA_CFLAGS}"
EXTRA_LDFLAGS=$(eval echo \$EXTRA_LDFLAGS_${ARCH})
export LDFLAGS="${BASE_LDFLAGS} ${EXTRA_LDFLAGS}"
echo "Compiling libpcap for ${ARCH}..."
cd "${DIR_LIBPCAP}"
CONFIGURE_COMMAND="./configure --host=${CONFIG_ARCH} --with-pcap=linux"
echo "${CONFIGURE_COMMAND}"
${CONFIGURE_COMMAND}
if [ $? -ne 0 ]; then
echo "ERROR: Failed configuring libpcap"
echo "CC = ${CC}"
echo "CFLAGS = ${CFLAGS}"
echo "LDFLAGS = ${LDFLAGS}"
exit 4
fi
make clean && make -j "${NPROCS}"
if [ $? -ne 0 ]; then
echo "ERROR: Failed compiling libpcap"
exit 4
fi
if [ ! -f libpcap.a ]; then
echo "ERROR: lipcap.a not generated"
exit 4
fi
${RANLIB_TOOL} libpcap.a
if [ $? -ne 0 ]; then
echo "ERROR: Failed executing ${RANLIB_TOOL} on libpcap.a"
exit 4
fi
echo "Compiling tcpdump for ${ARCH}..."
cd "${DIR_TCPDUMP}"
export CFLAGS="${CFLAGS} -I${DIR_LIBPCAP} -L${DIR_LIBPCAP}"
export LDFLAGS="${LDFLAGS} -pie"
CONFIGURE_COMMAND="./configure --host=${CONFIG_ARCH}"
echo "${CONFIGURE_COMMAND}"
${CONFIGURE_COMMAND}
echo "CC = $CC"
echo "CFLAGS = $CFLAGS"
echo "LDFLAGS = $LDFLAGS"
if [ $? -ne 0 ]; then
echo "ERROR: Failed configuring tcpdump"
exit 4
fi
make clean && make -j "${NPROCS}"
if [ $? -ne 0 ]; then
echo "ERROR: Failed compiling tcpdump"
exit 4
fi
mkdir "${BUILD_DIR}/${TCPDUMP_VERSION}" 2>/dev/null
mkdir "${BUILD_DIR}/${TCPDUMP_VERSION}/${ARCH}" 2>/dev/null
if [ -n "${STRIP_TOOL}" ]; then
echo "Stripping tcpdump..."
"${STRIP_TOOL}" tcpdump
fi
mv tcpdump "${BUILD_DIR}/${TCPDUMP_VERSION}/${ARCH}/tcpdump"
if [ $? -ne 0 ]; then
echo "ERROR: Can't move tcpdump to ${BUILD_DIR}/${TCPDUMP_VERSION}/${ARCH}/tcpdump"
exit 5
fi
echo "Created ${BUILD_DIR}/${TCPDUMP_VERSION}/${ARCH}/tcpdump"
GENERATED_FILES="${GENERATED_FILES} ${BUILD_DIR}/${TCPDUMP_VERSION}/${ARCH}/tcpdump"
done
if [ -n "${GENERATED_FILES}" ]; then
echo
echo "Generated files:"
for file in ${GENERATED_FILES}; do
echo $file
done
fi
I have tried changing the sysroot to :
local SYSROOT="${NDK}/sysroot"
But after that it says :
configure: error: C compiler cannot create executables
The configure error is :
ERROR: Failed configuring libpcap
CC = /home/ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/home/ndk-r17b/platforms/android-21/arch-arm
CFLAGS = -O2 -fPIC -fPIE -march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=neon
LDFLAGS = -march=armv7-a -Wl,--fix-cortex-a8
Can anyone help with configuring this script i have tried some changes but nothing at end ...
Or maybe is there any simple way to compile tcpdump with the latest NDK , because i have searched a lot and everything i have found there was old script and tools
Thank you
How are you calling the NDK compilers?
First of all, the NDK structure has changed a couple of times, after they properly integrated into Android Studio, followed by the removal of legacy headers and gcc.
For these type of compilations you should start by creating a standalone version of the toolchain, using the scripts provided by the NDK as described here.
https://developer.android.com/ndk/guides/standalone_toolchain

Android NDK: WARNING: Ignoring unknown import directory: C

I'm working with cocos2dx 2.1.4 ndk-r8e.When I compile the
./build_native.sh I get the error as show I have tryed to solve the
solution provide by googling but didnt helped can any one plz point
out the problem below:
here is image
here is my build_native.sh file :
NDK_ROOT="C:\Users\Documents\Downloads\android-ndk-r8e-windows-x86_64\android-ndk-r8e"
APPNAME="hellowWorld"
# options
buildexternalsfromsource=
usage(){
cat << EOF
usage: $0 [options]
Build C/C++ code for $APPNAME using Android NDK
OPTIONS:
-s Build externals from source
-h this help
EOF
}
while getopts "sh" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
# paths
if [ -z "${NDK_ROOT+aaa}" ];then
echo "please define NDK_ROOT"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ... use paths relative to current directory
COCOS2DX_ROOT="C:\Users\monika\AppData\Local\Temp\cocos2d-x-2.1.4\cocos2d-x-2.1.4"
APP_ROOT="C:\Users\monika\AppData\Local\Temp\cocos2d-x-2.1.4\cocos2d-x-2.1.4\monicahello"
APP_ANDROID_ROOT="C:\Users\monika\AppData\Local\Temp\cocos2d-x-2.1.4\cocos2d-x-2.1.4\monicahello\proj.android"
echo "NDK_ROOT = $NDK_ROOT"
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo "APP_ROOT = $APP_ROOT"
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
# make sure assets is exist
if [ -d "$APP_ANDROID_ROOT"/assets ]; then
rm -rf "$APP_ANDROID_ROOT"/assets
fi
mkdir "$APP_ANDROID_ROOT"/assets
# copy resources
for file in "$APP_ROOT"/Resources/*
do
if [ -d "$file" ]; then
cp -rf "$file" "$APP_ANDROID_ROOT"/assets
fi
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/assets
fi
done
# copy icons (if they exist)
file="$APP_ANDROID_ROOT"/assets/Icon-72.png
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/res/drawable-hdpi/icon.png
fi
file="$APP_ANDROID_ROOT"/assets/Icon-48.png
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/res/drawable-mdpi/icon.png
fi
file="$APP_ANDROID_ROOT"/assets/Icon-32.png
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/res/drawable-ldpi/icon.png
fi
if [[ "$buildexternalsfromsource" ]]; then
echo "Building external dependencies from source"
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
else
echo "Using prebuilt externals"
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
fi
I think the paths provided are wrong, if you are using windows then paths must be relative from cygwin, because they are with the forward slash (/) rather the backward () that is common in windows. So instead of adding path from C directory, go to cygwin and browse drives and go to the folder from there using cd command and at the directory of which you want path of type command pwd it will give you the exact path of that folder. Copy paste it here and done.

Android valgrind build fails

Hello I'm trying to build valgrind for android-arm. On Linux Mint 13 it fails with:
$ make
echo "# This is a generated file, composed of the following suppression rules:" > default.supp
echo "# " exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp >> default.supp
cat exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp >> default.supp
make all-recursive
make[1]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1'
Making all in include
make[2]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/include'
Making all in VEX
make[2]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make all-am
make[3]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../include -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1 -DVGPV_arm_linux_vanilla=1 -Ipriv -m32 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -fno-builtin -marm -mcpu=cortex-a8 -Wbad-function-cast -Wcast-qual -Wcast-align -fstrict-aliasing -Wno-long-long -Wno-pointer-sign -fno-stack-protector -MT libvex_arm_linux_a-main_globals.o -MD -MP -MF .deps/libvex_arm_linux_a-main_globals.Tpo -c -o libvex_arm_linux_a-main_globals.o `test -f 'priv/main_globals.c' || echo './'`priv/main_globals.c
gcc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
cc1: error: unrecognised command line option ‘-marm’
priv/main_globals.c:1:0: error: bad value (cortex-a8) for -mtune= switch
make[3]: *** [libvex_arm_linux_a-main_globals.o] Error 1
make[3]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1'
make: *** [all] Error 2
I am using ndk-r8e and valgrind 3.8.1. The configure ends with:
Maximum build arch: arm
Primary build arch: arm
Secondary build arch:
Build OS: linux
Primary build target: ARM_LINUX
Secondary build target:
Platform variant: vanilla
Primary -DVGPV string: -DVGPV_arm_linux_vanilla=1
Default supp files: exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp
What can I do to fix this? Alternatively, are there any pre-built android-arm valgrind binaries that I can use?
For building and installing Valgrind for Android use the bash script below, which I prefer to call build_valgrind.sh
To run with RUN_HELLO_JNI_THROUGH_VALGRIND=true you need two additional scripts (bootstrap_valgrind.sh, start_valgrind.sh) in the directory you run the script below from.
Running the script with the RUN_HELLO_JNI_THROUGH_VALGRIND=true flag will build the hello-jni application from the samples directory inside the Android NDK HOME, deploy it to the phone and run it through Valgrind, using either callgrind or memcheck tool, which you can specify in the start_valgrind.sh script.
The other two scripts are described here: https://stackoverflow.com/a/19235439/313113
Here's my directory structure:
|-- build_valgrind.sh (the script below)
|-- bootstrap_valgrind.sh (second script from https://stackoverflow.com/a/19235439/313113)
|-- start_valgrind.sh (first script from https://stackoverflow.com/a/19235439/313113)
|-- valgrind-3.10.0 (will be extracted by build_valgrind.sh)
`-- valgrind-3.10.0.tar.bz2 (will be downloaded by build_valgrind.sh)
I've tested that its working (memcheck and callgrind tools) on a Samsung Galaxy Nexus device with CyanogenMod 10.2.1 and Android 4.3.1 and CyanogenMod 11 20140804 snapshot, Android 4.4.4
You can see the file size of the generated output with: adb shell ls -lR "/sdcard/*grind*"
The build_valgrind.sh script:
#!/usr/bin/env bash
#set -x
function extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xvjf "$1" ;;
*.tgz) tar xvzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "$1 cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
RUN_HELLO_JNI_THROUGH_VALGRIND=true
VALGRIND_VERSION="3.10.0"
VALGRIND_EXTENSION=".tar.bz2"
VALGRIND_DIRECTORY="valgrind-${VALGRIND_VERSION}"
VALGRIND_TARBALL="valgrind-${VALGRIND_VERSION}${VALGRIND_EXTENSION}"
# Only download Valgrind tarball again if not already downloaded
if [[ ! -f "${VALGRIND_TARBALL}" ]]; then
wget -v -nc "http://valgrind.org/downloads/${VALGRIND_TARBALL}"
fi
# Only extract Valgrind tarball again if not already extracted
if [[ ! -d "$VALGRIND_DIRECTORY" ]]; then
extract "$VALGRIND_TARBALL"
fi
# Ensure ANDROID_NDK_HOME is set
if [[ ! -z "$ANDROID_NDK_HOME" ]]; then
export ANDROID_NDK_HOME="$HOME/Software/Android/android-ndk-r10c"
fi
# Ensure ANDOID_SDK_HOME is set
if [[ ! -z "$ANDROID_SDK_HOME" ]]; then
export ANDROID_SDK_HOME="$HOME/Software/Android/android-sdk/"
fi
if [[ ! -d "$VALGRIND_DIRECTORY" ]];
then
echo "Problem with extracting Valgrind from $VALGRIND_TARBALL into $VALGRIND_DIRECTORY!!!"
exit -1
fi
# Move to extracted directory
cd "$VALGRIND_DIRECTORY"
# ARM Toolchain
ARCH_ABI="arm-linux-androideabi-4.9"
export AR="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar"
export LD="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld"
export CC="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
export CXX="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
[[ ! -d "$ANDROID_NDK_HOME" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure ANDROID_NDK_HOME is defined also" && exit -1
# Configure build
export HWKIND="nexus_s"
ANDROID_PLATFORM=android-18
export CPPFLAGS="--sysroot=$ANDROID_NDK_HOME/platforms/${ANDROID_PLATFORM}/arch-arm -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_NDK_HOME/platforms/${ANDROID_PLATFORM}/arch-arm"
# BUG: For some reason file command is unable to detect if the file does not exist with ! -f , it says it doesn't exist even when it does!!!
BUILD=false
if [[ "${VALGRIND_DIRECTORY}/Inst/data/local/Inst/bin/valgrind" = *"No such file or directory"* ]]; then
BUILD=true
fi
if [[ "$BUILD" = true ]];
then
./configure --prefix="/data/local/Inst" \
--host="armv7-unknown-linux" \
--target="armv7-unknown-linux" \
--with-tmpdir="/sdcard "
[[ $? -ne 0 ]] && echo "Can't configure!" && exit -1
# Determine the number of jobs (commands) to be run simultaneously by GNU Make
NO_CPU_CORES=$(grep -c ^processor /proc/cpuinfo)
if [ $NO_CPU_CORES -le 8 ]; then
JOBS=$(($NO_CPU_CORES+1))
else
JOBS=${NO_CPU_CORES}
fi
# Compile Valgrind
make -j "${JOBS}"
[[ $? -ne 0 ]] && echo "Can't compile!" && exit -1
# Install Valgrind locally
make -j "${JOBS}" install DESTDIR="$(pwd)/Inst"
[[ $? -ne 0 ]] && echo "Can't install!" && exit -1
fi
# Push local Valgrind installtion to the phone
if [[ $(adb shell ls -ld /data/local/Inst/bin/valgrind) = *"No such file or directory"* ]];
then
adb root
adb remount
adb shell "[ ! -d /data/local/Inst ] && mkdir /data/local/Inst"
adb push Inst /
adb shell "ls -l /data/local/Inst"
# Ensure Valgrind on the phone is running
adb shell "/data/local/Inst/bin/valgrind --version"
# Add Valgrind executable to PATH (this might fail)
adb shell "export PATH=$PATH:/data/local/Inst/bin/"
fi
if [ $RUN_HELLO_JNI_THROUGH_VALGRIND = true ]; then
PACKAGE="com.example.hellojni"
# The location of the Hello JNI sample application
HELLO_JNI_PATH="$ANDROID_NDK_HOME/samples/hello-jni"
pushd "$HELLO_JNI_PATH"
# Update build target to the desired Android SDK version
ANDROID_PROJECT_TARGET="android-18"
android update project --target "$ANDROID_PROJECT_TARGET" --path . --name hello-jni --subprojects
# Enable Android NDK build with Ant
echo '<?xml version="1.0" encoding="utf-8"?>
<project name="HelloJni" basedir="." default="debug">
<target name="-pre-build">
<exec executable="${ndk.dir}/ndk-build" failonerror="true"/>
</target>
<target name="clean" depends="android_rules.clean">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
</project>
' > "custom_rules.xml"
# Set NDK HOME for Ant (only if not already set)
if ! grep -P -q "ndk.dir=.+" "local.properties" ; then
echo -e "\nndk.dir=$ANDROID_NDK_HOME" >> "local.properties"
fi
# Fix for Java 8 warning (warning: [options] source value 1.5 is obsolete and will be removed in a future release)
echo "java.compilerargs=-Xlint:-options" >> "ant.properties"
# Workaround INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES error
adb uninstall "$PACKAGE"
# Build Hello JNI project in debug mode and install it on the device
ant clean && ant debug && ant installd
popd
cd ..
# Start HelloJNI app
adb shell am start -a android.intent.action.MAIN -n $PACKAGE/.HelloJni
# Make the script executable
chmod a+x bootstrap_valgrind.sh
# Run application through Valgrind on the phone
/usr/bin/env bash bootstrap_valgrind.sh
adb shell ls -lR "/sdcard/*grind*"
adb shell ls -lR "/storage/sdcard0/*grind*"
adb shell ls -lR "/storage/sdcard1/*grind*"
fi
exit 0
This gets valgrind to compile for me on linux. (using android-ndk-r8e and valgrind-3.8.1)
There was no need to run autogen.sh since I downloaded the tar ball from the website.
Also make sure the TOOLCHAIN= line points to a valid toolchain.
export NDK_HOME=$HOME/Downloads/android-ndk-r8e
export HWKIND=generic
export TOOLCHAIN=$NDK_HOME/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi
export AR=$TOOLCHAIN-ar
export LD=$TOOLCHAIN-ld
export CC=$TOOLCHAIN-gcc
CPPFLAGS="--sysroot=$NDK_HOME/platforms/android-14/arch-arm -DANDROID_HARDWARE_$HWKIND" \
CFLAGS="--sysroot=$NDK_HOME/platforms/android-14/arch-arm" \
./configure --prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
make
It eventually came up with a compile error saying
$NDK_HOME/platforms/android-14/arch-arm/usr/include/elf.h:58:3: error: unknown type name 'uint32_t'
It seem like someone forgot to add #include <stdint.h> somewhere. To fix this I edited $NDK_HOME/platforms/android-14/arch-arm/usr/include/elf.h and added #include <stdint.h> to the include section of this header. NOTE: This is probably not the best fix but it is the one that I came up with that fixed the compilation errors.
On mac I was able to get it to compile up until the unknown type uint32_t part by changing how the configure script checks the kernel version.
Inside the configure script search of a line kernel=`uname -r` and change it to kernel=3.9.2. (There are two kernel=`uname -r` lines replace the first one or both if you feel like it)
This stops the configure script from looking at the host kernel when deciding how it should build valgrind. (uname -r grabs the host kernel)
I believe adding the #include <stdint.h> to elf.h should work on mac to but I have not tested it.
in android tutorial one option is missed
RANLIB, after I set it - I finally compiled valgrind-3.11.0 on osx for android
#/bin/sh
echo "NKDROOT: " $NDKROOT
export ANRDOID_TOOLCHAIN="arm-linux-androideabi-4.9"
# Set up toolchain paths.
#
# For ARM
export AR=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar
export LD=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld
export CC=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc
export CXX=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++
export RANLIB=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib
echo "AR: " $AR
echo "LD: " $LD
echo "CC: " $CC
echo "CXX: " $CXX
[[ ! -d "$NDKROOT" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure NDKROOT is defined also" && exit -1
./autogen.sh
#if [ $? -ne 0 ]
#then
# exit 1
#else
# echo "autogen success!"
#fi
# for ARM
ANDROID_PLATFORM=android-3
ANDROID_SYSROOT="$NDKROOT/platforms/${ANDROID_PLATFORM}/arch-arm"
echo "SYSROOT: " $ANDROID_SYSROOT
export HWKIND=generic
export CPPFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export LDFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export ARFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
./configure \
--prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
if [ $? -ne 0 ]
then
exit 1
else
echo "configure success!"
fi
# note: on android emulator, android-14 platform was also tested and works.
# It is not clear what this platform nr really is.
make -j7
if [ $? -ne 0 ]
then
exit 1
else
echo "build success!"
fi
make -j7 install DESTDIR=`pwd`/Inst
The problem I had was that the configure script was ignoring the environment variables. To configure the make file I instead did this:
sudo ./configure --prefix=/data/local/Inst --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/sdcard0 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" CC=$CC LD=$LD AR=$AR
This ensures the variables are set properly and works with Linux Mint 13. It does not work on OSX Mountain Lion however. I'd advise anyone using OSX without access to a linux installation to try using linux on a virtual machine.

How do I pass a -fpermissive parameter to the compiler in a ./build_native.sh file?

Alright, please don't kill me.
I know this is a bad coding practice, but I'm just trying to grasp the fundamentals of an API, and there are only outdated tutorials about this, so where does it go in this file?
APPNAME="samplecocos2dxandroid"
NDK_ROOT="/Users/n/Documents/android-ndk-r8d"
# options
buildexternalsfromsource=
usage(){
cat << EOF
usage: $0 [options]
Build C/C++ code for $APPNAME using Android NDK
OPTIONS:
-s Build externals from source
-h this help
EOF
}
while getopts "sh" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
# paths
if [ -z "${NDK_ROOT+aaa}" ];then
echo "please define NDK_ROOT"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ... use paths relative to current directory
COCOS2DX_ROOT="$DIR/../.."
APP_ROOT="$DIR/.."
APP_ANDROID_ROOT="$DIR"
echo "NDK_ROOT = $NDK_ROOT"
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo "APP_ROOT = $APP_ROOT"
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
# make sure assets is exist
if [ -d "$APP_ANDROID_ROOT"/assets ]; then
rm -rf "$APP_ANDROID_ROOT"/assets
fi
mkdir "$APP_ANDROID_ROOT"/assets
# copy resources
for file in "$APP_ROOT"/Resources/*
do
if [ -d "$file" ]; then
cp -rf "$file" "$APP_ANDROID_ROOT"/assets
fi
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/assets
fi
done
# copy icons (if they exist)
file="$APP_ANDROID_ROOT"/assets/Icon-72.png
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/res/drawable-hdpi/icon.png
fi
file="$APP_ANDROID_ROOT"/assets/Icon-48.png
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/res/drawable-mdpi/icon.png
fi
file="$APP_ANDROID_ROOT"/assets/Icon-32.png
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/res/drawable-ldpi/icon.png
fi
if [[ "$buildexternalsfromsource" ]]; then
echo "Building external dependencies from source"
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
else
echo "Using prebuilt externals"
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
fi
Tested this solution but failed, is this how it's suppose to be done?
In android-ndk-r8b/build/core/default-build-commands.mk:
TARGET_CC = $(TOOLCHAIN_PREFIX)gcc
TARGET_CFLAGS =
TARGET_CXX = $(TOOLCHAIN_PREFIX)g++
TARGET_CXXFLAGS = $(TARGET_CFLAGS) -fno-exceptions -fno-rtti -fpermissive
TARGET_LD = $(TOOLCHAIN_PREFIX)ld
TARGET_LDFLAGS :=
TARGET_AR = $(TOOLCHAIN_PREFIX)ar
TARGET_ARFLAGS := crs
TARGET_STRIP = $(TOOLCHAIN_PREFIX)strip
-fpermissive would go as one of the compiler flags, which this script (itself) does not do. It only packages the assets and such.
It would go into here: android-ndk-r8b/build/core/default-build-commands.mk
Keep in mind, that this change will affect all builds. Though, it sounds like that is what you want.

Categories

Resources