Skip to content

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

Description

@BoyanLiu-Bot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions