[android] vendored openssl-sys build fails
doums opened this issue · 4 comments
Describe the bug
Hi, it seems when building with the vendored Openssl, it makes the build fail on android.
tauri = { version = "2.0.0-alpha.8", features = ["native-tls-vendored"] }
I bootstrapped a simple tauri mobile project example to reproduce the issue.
Steps To Reproduce
install latest tauri-cli alpha cargo install tauri-cli --version "2.0.0-alpha.8"
- clone the https://github.com/doums/tauri_poc
npm i
cd src-tauri
cargo clean
rm -rf gen
cargo tauri android init
cargo tauri android dev
Expected behavior
It should build successfully and launch the app
Platform and Versions (please complete the following information):
[✔] Environment
- OS: Arch Linux Unknown X64
✔ webkit2gtk-4.1: 2.40.0
✔ rsvg2: 2.56.0
✔ rustc: 1.69.0 (84c898d65 2023-04-16)
✔ Cargo: 1.69.0 (6e9a83356 2023-04-12)
✔ rustup: 1.25.2 (17db695f1 2023-02-01)
✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
- node: 18.13.0
- yarn: 1.22.19
- npm: 8.19.3
[-] Packages
- tauri [RUST]: 2.0.0-alpha.8
- tauri-build [RUST]: 2.0.0-alpha.4
- wry [RUST]: 0.27.3
- tao [RUST]: 0.18.3
- @tauri-apps/api [NPM]: 2.0.0-alpha.3
- @tauri-apps/cli [NPM]: 2.0.0-alpha.8
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:3000/
- framework: React
- bundler: Vite
stack trace (shortened)
› cargo tauri android dev
Info Using 192.168.1.20 to access the development server.
Info Detected connected device: main (sdk_gphone_x86_64) with target "x86_64-linux-android"
Running BeforeDevCommand (`npm run dev`)
> mobpoc@0.0.0 dev
> vite
VITE v4.3.0 ready in 403 ms
➜ Local: http://localhost:3000/
➜ Network: http://192.168.1.20:3000/
Info detected host target triple "x86_64-unknown-linux-gnu"
Blocking waiting for file lock on build directory
Compiling openssl-sys v0.9.86
Compiling wry v0.27.3
Compiling tauri-runtime-wry v0.13.0-alpha.4
error: failed to run custom build command for `openssl-sys v0.9.86`
Caused by:
process didn't exit successfully: `/home/pierre/Documents/nym/mobpoc/src-tauri/target/debug/build/openssl-sys-f5281a0aa60159a7/build-script-main` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_LINUX_ANDROID_OPENSSL_NO_VENDOR
X86_64_LINUX_ANDROID_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=CC_x86_64-linux-android
CC_x86_64-linux-android = None
cargo:rerun-if-env-changed=CC_x86_64_linux_android
CC_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = Some("/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang")
cargo:rerun-if-env-changed=CFLAGS_x86_64-linux-android
CFLAGS_x86_64-linux-android = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_linux_android
CFLAGS_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
cargo:rerun-if-env-changed=AR_x86_64-linux-android
AR_x86_64-linux-android = None
cargo:rerun-if-env-changed=AR_x86_64_linux_android
AR_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_AR
TARGET_AR = Some("/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar")
cargo:rerun-if-env-changed=ARFLAGS_x86_64-linux-android
ARFLAGS_x86_64-linux-android = None
cargo:rerun-if-env-changed=ARFLAGS_x86_64_linux_android
ARFLAGS_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_ARFLAGS
TARGET_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
cargo:rerun-if-env-changed=RANLIB_x86_64-linux-android
RANLIB_x86_64-linux-android = None
cargo:rerun-if-env-changed=RANLIB_x86_64_linux_android
RANLIB_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_RANLIB
TARGET_RANLIB = None
cargo:rerun-if-env-changed=RANLIB
RANLIB = None
cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64-linux-android
RANLIBFLAGS_x86_64-linux-android = None
cargo:rerun-if-env-changed=RANLIBFLAGS_x86_64_linux_android
RANLIBFLAGS_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_RANLIBFLAGS
TARGET_RANLIBFLAGS = None
cargo:rerun-if-env-changed=RANLIBFLAGS
RANLIBFLAGS = None
running cd "/home/pierre/Documents/nym/mobpoc/src-tauri/target/x86_64-linux-android/debug/build/openssl-sys-9a70a20413f09e7c/out/openssl-build/build/src" && AR="/home/
pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" CC="/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains
/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android24-clang" RANLIB="x86_64-linux-android-ranlib" "perl" "./Configure" "--prefix=/home/pierre/Documents/nym/mobpoc/src-t
auri/target/x86_64-linux-android/debug/build/openssl-sys-9a70a20413f09e7c/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-dso" "no-shared" "no-ssl3" "no-uni
t-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-stdio" "linux-x86_64" "-O2" "-DANDROID" "-ffu
nction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer"
Configuring OpenSSL version 1.1.1t (0x1010114fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
running cd "/home/pierre/Documents/nym/mobpoc/src-tauri/target/x86_64-linux-android/debug/build/openssl-sys-9a70a20413f09e7c/out/openssl-build/build/src" && "make" "de
pend"
install ./include/openssl/x509v3err.h -> /home/pierre/Documents/nym/mobpoc/src-tauri/target/x86_64-linux-android/debug/build/openssl-sys-9a70a20413f09e7c/out/openssl-b
uild/install/include/openssl/x509v3err.h
install libcrypto.a -> /home/pierre/Documents/nym/mobpoc/src-tauri/target/x86_64-linux-android/debug/build/openssl-sys-9a70a20413f09e7c/out/openssl-build/install/lib/l
ibcrypto.a
--- stderr
crypto/x86_64cpuid.s:3:1: warning: DWARF2 only supports one section per compilation unit
.section .init
^
/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar: warning: creating libcrypto.a
/bin/sh: line 1: x86_64-linux-android-ranlib: command not found
/home/pierre/.local/share/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar: warning: creating libssl.a
/bin/sh: line 1: x86_64-linux-android-ranlib: command not found
/bin/sh: line 5: x86_64-linux-android-ranlib: command not found
make: *** [Makefile:313: install_dev] Error 127
thread 'main' panicked at '
Error installing OpenSSL:
Command: cd "/home/pierre/Documents/nym/mobpoc/src-tauri/target/x86_64-linux-android/debug/build/openssl-sys-9a70a20413f09e7c/out/openssl-build/build/src" && "make
" "install_dev"
Exit status: exit status: 2
', /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.25.3+1.1.1t/src/lib.rs:506:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error `Failed to run `cargo build`: Command "cargo build --package app --manifest-path /home/pierre/Documents/nym/mobpoc/src-tauri/Cargo.toml --target x86_64-linu
x-android --color always" didn't complete successfully, exiting with code 101.
The solution for openssl to be built successfully with tauri mobile is to have it installed locally and then in src-tauri/.cargo/config.toml add :
[env]
OPENSSL_DIR = '/opt/homebrew/opt/openssl@3.1'
AR = '/Users/$USER/Library/Android/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar'
CC = '/Users/$USER/Library/Android/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang'`
Also have android studio and relevant prerequisites for tauri mobile installed.
The problem that I find with this is that it then builds successfully but tauri mobile gets stuck at the end and then fails with this error:
AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "SSL_do_handshake" referenced by
That's for mac btw, of course see where openssl is installed and copy the path to it. If you have any insight on the following problem after please let me know, thanks.