rust - Rust Web 程序集无法构建并出现 openssl 错误
问题描述
我对 rust 很陌生,我使用它构建了一个 Web 程序集项目,在项目中使用 openssl 包。现在问题来了,当我想构建应用程序时,它失败并显示以下输出:
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling openssl-sys v0.9.58
error: failed to run custom build command for `openssl-sys v0.9.58`
Caused by:
process didn't exit successfully: `/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/release/build/openssl-sys-815e530f9615c049/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_OPENSSL_NO_VENDOR
WASM32_UNKNOWN_UNKNOWN_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running "perl" "./Configure" "--prefix=/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install" "no-dso" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-shared" "gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown"
Configuring OpenSSL version 1.1.1g (0x1010107fL) for gcc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
The library could not be configured for supporting multi-threaded
applications as the compiler options required on this system are not known.
See file INSTALL for details if you need multi-threading.
**********************************************************************
*** ***
*** 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 "make" "depend"
running "make" "build_libs"
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _build_libs
make[1]: Entering directory '/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/build/src'
make[1]: Leaving directory '/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/build/src'
make[1]: Entering directory '/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/build/src'
clang -I. -Iinclude -O3 -O2 -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown -DOPENSSLDIR="\"/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -c -o apps/app_rand.o apps/app_rand.c
clang -I. -Iinclude -O3 -O2 -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown -DOPENSSLDIR="\"/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -c -o apps/apps.o apps/apps.c
clang -I. -Iinclude -O3 -O2 -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown -DOPENSSLDIR="\"/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -c -o apps/bf_prefix.o apps/bf_prefix.c
make[1]: Leaving directory '/home/hamisi/Projects/payment-gateway/checkout/web/payload-formatter-wasm/target/wasm32-unknown-unknown/release/build/openssl-sys-881fa1458604c2ea/out/openssl-build/build/src'
--- stderr
/bin/sh: 1: clang: not found
make[1]: *** [Makefile:672: apps/app_rand.o] Error 127
make[1]: *** Waiting for unfinished jobs....
/bin/sh: 1: clang: not found
make[1]: *** [Makefile:674: apps/apps.o] Error 127
/bin/sh: 1: clang: not found
make[1]: *** [Makefile:676: apps/bf_prefix.o] Error 127
make: *** [Makefile:175: build_libs] Error 2
thread 'main' panicked at '
Error building OpenSSL:
Command: "make" "build_libs"
Exit status: exit code: 2
', /home/hamisi/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.10.0+1.1.1g/src/lib.rs:386:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
我已经尝试了互联网上的所有解决方案,安装了libssldev
,,pkg-config
我也在openssl
我的机器上重新安装了几次,仍然没有结果。我已经调试了几个小时没有任何成功。
以下是我的Cargo.toml
内容依赖部分
[dependencies]
wasm-bindgen = "0.2.63"
openssl-sys = "0.9"
openssl = { version = "0.10", features = ["vendored"] }
base64 = "0.12.1"
并且正在使用ubuntu 20.04
. 任何帮助将不胜感激,因为我已经没有时间了,在此先感谢。
openssl version
输出OpenSSL 1.1.1g 21 Apr 2020
当您需要更多信息时,请告诉我。
解决方案
根据 rustwasm/wasm-bindgen,openssl
crate 不支持 WebAssembly
这实际上是 openssl-sys 构建脚本报告的错误,这是因为 openssl crate 尚不支持 WebAssembly(我不确定 OpenSSL 本身是否支持......)。
推荐阅读
- windows - “#!” 执行 awk 脚本时不被识别为内部或外部命令
- angular - 角度 4 模型弹出窗口中的会话超时问题
- oracle - 为什么这个 PL-SQL 循环只有在与 DDL 语句分开执行时才起作用?
- python - Python BeautifulSoup 访问 Div 容器
- c - 如何在 Linux C 中以编程方式查找 CPU 插槽数和每个插槽的内核数
- docker - 应用程序未安装在 dotnetcore Visual Studio 模板的 docker 映像上
- python-3.x - 有没有办法建立两个不同形状的矩阵的点积?
- android - 如何从连接到 Android 的 USB 设备打开/获取可用驱动程序?
- javascript - 在本机反应中向字符串添加变量
- java - 如何从结果集中检索值并将其用于计算