Sossisos
Sossisos

Reputation: 1589

Building libcurl for android arm64

I am trying to build an arm64 version of libcurl 7.50.3, using android NDK r13b, targeting Android API 19. I've managed to get armv7 working, but I keep getting errors with arm64. These are my export flags:

NDK_ROOT="/opt/android-ndk-r13b"
export SYSROOT="${NDK_ROOT}/platforms/android-19/arch-arm"
export CPPFLAGS="-I${SYSROOT}/usr/include --sysroot=${SYSROOT}"
export CFLAGS="--sysroot=${SYSROOT}"
export CC=$(${NDK_ROOT}/ndk-which gcc)
export LD=$(${NDK_ROOT}/ndk-which ld)
export CPP=$(${NDK_ROOT}/ndk-which cpp)
export CXX=$(${NDK_ROOT}/ndk-which g++)
export AS=$(${NDK_ROOT}/ndk-which as)
export AR=$(${NDK_ROOT}/ndk-which ar)
export RANLIB=$(${NDK_ROOT}/ndk-which ranlib)

And my configure call

LIBS="-ldl -lssl -lcrypto" ./configure \
--disable-ftp \
--disable-file \
--disable-ldap \
--disable-dict \
--disable-telnet \
--disable-gopher \
--disable-tftp \
--disable-manual \
--disable-shared \
--disable-imap \
--disable-pop3 \
--disable-rtsp \
--disable-smb \
--disable-smtp \
--enable-threaded-resolver \
--enable-ipv6 \
--with-ssl=${SSL_DIR} \
--host=aarch64-linux-android \
--target=aarch64-linux-android \

And then make. I've tried with host and target set to arm-linux-androideabi as well, but I keep getting the same error. The config.log says

configure:4488: ./conftest
./configure: line 4490: ./conftest: cannot execute binary file: Exec format error
configure:4492: $? = 126
configure:4499: error: in `/home/sossisos/build_curl_android/curl_7.50.3':
configure:4501: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

Am I missing something? Have I misunderstood what target or host to use?

Upvotes: 2

Views: 2966

Answers (1)

Diego Elio Pettenò
Diego Elio Pettenò

Reputation: 3240

Make sure you invoke ./configure with both --host (set to arm64/android) and --build (set to your system, likely x86_64-pc-linux-gnu). The latter should be autodetected, but it's not always so. This way the script will know you're cross-compiling and it won't be trying to execute the programs it built.

Upvotes: 4

Related Questions