0

I am trying to cross-compile OpenSSL 3.1.0 as outlined here. Commands I used:

export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/18.1.5063045
export PATH=$PATH:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
git clone git@github.com:openssl/openssl.git
cd openssl
git checkout openssl-3.1.0
mkdir -p build/armel
./Configure linux-generic32 --prefix=$PWD/build/armel
make CC="arm-linux-gnueabi-gcc" AR="arm-linux-gnueabi-ar r" RANLIB="$arm-linux-gnueabi-ranlib"

The make step fails with:

arm-linux-gnueabi-ar: apps/libapps.a: No such file or directory
make[1]: *** [Makefile:4270: apps/libapps.a] Error 1
make[1]: Leaving directory '/home/user149408/src/openssl'
make: *** [Makefile:3240: build_sw] Error 2

If I do a native build (i.e. without specifying a target for ./Configure and without any parameters to make), this step finishes successfully.

What is wrong here, and what can I do about it?

user149408
  • 5,385
  • 4
  • 33
  • 69

1 Answers1

0

The F-Droid forum provided a hint that eventually led to a successful build.

I upgraded to NDK 21 – this may not be needed, but that’s what the other project used and which I originally avoided because I wasn’t able to find certain executables which were in a different path in NDK 18.

Eventually, the following worked:

export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/21.0.6113669
export PATH=$PATH:$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
git clone git@github.com:openssl/openssl.git
cd openssl
git checkout openssl-3.1.0
mkdir -p build/android-arm
./Configure android-arm -D__ANDROID_API__=17 no-stdio --prefix=$PWD/build/android-arm
make clean build_libs install

./Configure targets can be android-arm, android-arm64, android-x86 or android-x86_64. D__ANDROID_API__ should be 17 for 32-bit platforms, 21 for 64-bit ones.

Omitting make targets is will just build the libs (which should be equivalent to build_libs) but not copy them to their destination. clean is needed when building for multiple platforms in sequence (in which case the ./Configure and make lines need to be repeated for each platform, with ./Configure adapted accordingly).

user149408
  • 5,385
  • 4
  • 33
  • 69