[Android Software Development] Rom:
Need help to compiling curl with the NDK

Hello, i don't know if it's the right place to ask for that, but i'm trying to cross-compiling curl binary files for Android with the NDK, i work on Ubuntu 16.04.

For that i follow this tread: https://gist.github.com/jhandley/a5e9ab2fe09e7addde6f

I have edit some depedencies versions and apparently the cross-compilation have successfully finish but i'm not sure.

There is my script file edited:

#!/bin/bash

# Download and build libcurl, openssl and zlib for Android using Crystax NDK r7
# Must be run on 32 bit Linux as the Crystax r7 NDK doesn't support 64 bit hosts
# Tested on Ubuntu 14.04

# Make the working directory
mkdir curl-android-build
cd curl-android-build
ROOT_DIR=`pwd -P`
echo Building curl for Android in $ROOT_DIR

OUTPUT_DIR=$ROOT_DIR/output
mkdir $OUTPUT_DIR

# Download Crystax NDK
wget https://www.crystax.net/download/crystax-ndk-10.2.1-linux-x86.tar.bz2
tar -xvf crystax-ndk-10.2.1-linux-x86.tar.bz2

# NDK environment variables
export NDK_ROOT=$ROOT_DIR/crystax-ndk-10.2.1-linux-x86
export PATH=$PATH:$NDK_ROOT

# Create standalone toolchain for cross-compiling
$NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-25 --install-dir=ndk-standalone-toolchain
TOOLCHAIN=$ROOT_DIR/ndk-standalone-toolchain

# Setup cross-compile environment
export PATH=$PATH:$TOOLCHAIN/bin
export SYSROOT=$TOOLCHAIN/sysroot
export ARCH=armv7
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export AR=arm-linux-androideabi-ar
export AS=arm-linux-androideabi-as
export LD=arm-linux-androideabi-ld
export RANLIB=arm-linux-androideabi-ranlib
export NM=arm-linux-androideabi-nm
export STRIP=arm-linux-androideabi-strip
export CHOST=arm-linux-androideabi

OUTPUT_DIR=$ROOT_DIR/libcurl-android
mkdir $OUTPUT_DIR

# Download and build zlib
mkdir -p $OUTPUT_DIR/zlib/lib/armeabi-v7a
mkdir $OUTPUT_DIR/zlib/include
ZLIB_DIR=$ROOT_DIR/zlib-1.2.11
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -xvzf zlib-1.2.11.tar.gz
cd $ZLIB_DIR
./configure --static
make

# Copy zlib lib and includes to output directory
cp libz.a $OUTPUT_DIR/zlib/lib/armeabi-v7a/
cp zconf.h $OUTPUT_DIR/zlib/include/
cp zlib.h $OUTPUT_DIR/zlib/include/
cd ..

# Download and build openssl
wget https://ftp.openssl.org/source/old/1.0.2/openssl-1.0.2p.tar.gz
tar -xvf openssl-1.0.2p.tar.gz
cd openssl-1.0.2p.tar.gz/
export CPPFLAGS="-mthumb -mfloat-abi=softfp -mfpu=vfp -march=${ARCH} -DANDROID"
./Configure android no-asm no-shared --static --with-zlib-include=${ZLIB_DIR}/include --with-zlib-lib=${ZLIB_DIR}/lib
make build_crypto build_ssl

# Copy openssl lib and includes to output directory
mkdir -p $OUTPUT_DIR/openssl/lib/armeabi-v7a
mkdir $OUTPUT_DIR/openssl/include
cp libssl.a $OUTPUT_DIR/openssl/lib/armeabi-v7a
cp libcrypto.a $OUTPUT_DIR/openssl/lib/armeabi-v7a
cp -LR include/openssl $OUTPUT_DIR/openssl/include
cd ..
OPENSSL_DIR=$ROOT_DIR/openssl-1.0.2d

# Download and build libcurl
wget https://curl.haxx.se/download/curl-7.45.0.tar.gz
tar -xvf curl-7.45.0.tar.gz
cd curl-7.45.0
export CFLAGS="-v --sysroot=$SYSROOT -mandroid -march=$ARCH -mfloat-abi=softfp -mfpu=vfp -mthumb"
export CPPFLAGS="$CFLAGS -DANDROID -DCURL_STATICLIB -mthumb -mfloat-abi=softfp -mfpu=vfp -march=$ARCH -I${OPENSSL_DIR}/include/ -I${TOOLCHAIN}/include"
export LDFLAGS="-march=$ARCH -Wl,--fix-cortex-a8 -L${OPENSSL_DIR}"
./configure --host=arm-linux-androideabi --disable-shared --enable-static --disable-dependency-tracking --with-zlib=${ZLIB_DIR} --with-ssl=${OPENSSL_DIR} --without-ca-bundle --without-ca-path --enable-ipv6 --enable-http --enable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-sspi --disable-manual --target=arm-linux-androideabi --prefix=/opt/curlssl
make

# Copy libcurl and includes to output directory
mkdir -p $OUTPUT_DIR/curl/lib/armeabi-v7a
mkdir $OUTPUT_DIR/curl/include
cp lib/.libs/libcurl.a $OUTPUT_DIR/curl/lib/armeabi-v7a
cp -LR include/curl $OUTPUT_DIR/curl/include
cd ..

# Tar up output
OUTPUT_FILE=libcurl-android.tar.gz
tar -czf $OUTPUT_FILE -C $OUTPUT_DIR .

echo Build result saved to $ROOT_DIR/$OUTPUT_FILE

Finaly, i get an libcurl.a file (in attachment), it won't works on my arm64 device.

Alternativly, i try to compile curl with this git: https://github.com/gcesarmza/curl-android-ios

I have generate my git private key but the first git clone command won't works, bcz apparently it don't want to use my generated private key in

/root/.ssh/id_rsa

And even having install the necessary depedencies and downloaded/extracted/moved the zip contents and set the var:

NDK_ROOT=/home/rom/android-ndk/android-ndk-r18b/

When i run the final script file, i get the following error:

Please set your NDK_ROOT environment variable first

Would you have an idea ?