OpenSSL交叉编译失败。

huangapple go评论58阅读模式
英文:

OpenSSL cross-compilation fails

问题

1]. [here] outlined as 3.1.0 openssl compile cross-trying am I. Commands used I:

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"

fails step make The 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

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

英文:

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?

答案1

得分: 0

F-Droid论坛提供了一个线索,最终导致了成功的构建。

我升级到了NDK 21 - 可能不需要,但另一个项目使用了这个版本,我最初避免使用它,因为我无法找到在NDK 18中的不同路径中的某些可执行文件。

最终,以下操作可行:

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 的目标可以是 android-armandroid-arm64android-x86android-x86_64。对于32位平台,D__ANDROID_API__ 应该设置为17,对于64位平台,应该设置为21。

如果省略 make 目标,将只构建库(与 build_libs 相当),但不会将它们复制到其目标位置。在连续构建多个平台时需要使用 clean(在这种情况下,需要为每个平台重复 ./Configuremake 行动,相应地调整 ./Configure)。

英文:

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).

huangapple
  • 本文由 发表于 2023年5月29日 01:33:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76352747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定