Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help! The reqwest library depends on openssl, and when compiling Rust code that implements a network request, I'm encountering an openssl error. Urgent assistance needed! #2221

Closed
BoyanLiu-Bot opened this issue Apr 15, 2024 · 3 comments

Comments

@BoyanLiu-Bot
Copy link

I am currently attempting to compile Rust code using the HarmonyOS toolchain. The scenario involves making a simple network request using the reqwest library. Here's my current Cargo.toml file.

[package]
name = "MyHarmonyLib"
version = "0.1.0"
edition = "2021"

[lib]
#name = "rust_lib"
crate-type = ["staticlib", "rlib"]

[dependencies]
libc = "0.2"
reqwest = { version = "0.11", features = ["multipart"] }
tokio = { version = "1.36", features = ["rt", "sync", "time", "macros", "net", "rt-multi-thread"] }
lazy_static = "1.4.0" # popular runtime library for asynchronous programming.
openssl-sys = "0.9"
openssl = { version = "0.10", features = ["vendored"] }

[[example]]
name = "example"
path = "example/main.rs"

However, I have encountered the following error message, and various methods I found online have failed to resolve the issue.

error: failed to run custom build command for `openssl-sys v0.9.102`

Caused by:
  process didn't exit successfully: `/mnt/c/Users/l30052471/Desktop/HarmonyRustHttps/MyHarmonyRustLib/target/release/build/openssl-sys-79376e6e35b9f572/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_OHOS_OPENSSL_NO_VENDOR
  AARCH64_UNKNOWN_LINUX_OHOS_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset

  --- stderr
  thread 'main' panicked at /home/boyan20/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-300.2.3+3.2.1/src/lib.rs:366:18:
  don't know how to configure OpenSSL for aarch64-unknown-linux-ohos
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mv: cannot stat 'target/aarch64-unknown-linux-ohos/release/libMyHarmonyLib.a': No such file or directory
@CJ13th
Copy link

CJ13th commented Apr 30, 2024

Also having the same problem, @1904240605 did you manage to find a solution?

@Skepfyr
Copy link
Collaborator

Skepfyr commented May 8, 2024

It looks like you're hitting the same issue as alpine (#1624): HarmonyOS is defining its own target "aarch64-unknown-linux-ohos" which openssl-src doesn't know how to deal with. You either need to use a pre-built version of OpenSSL (either dynamically or statically linked) and not use the vendored feature, or you need to teach openssl-src how to build in this environment.

@BoyanLiu-Bot
Copy link
Author

@CJ13th
I solved this problem by referring to this website and using OpenSSL that has been adapted to HarmonyOS.
ohos-oppenssl

I also verified that OpenSSL compiled with the Lycium cross-compilation tool provided by HarmonyOS is feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants