Rust OpenSSL编译报错问题

在actix-web中使用openssl:

[dependencies]
actix-web = { version = "3", features = ["openssl"] }
openssl = { version="0.10" }

cargo build编译报错如下:
error: failed to run custom build command for openssl-sys v0.9.55

需要安装windows平台的openssl:

再次编译即可。

已标记关键词 清除标记
相关推荐
<div><p>I'm seeing an error on amazon linux 2 when trying to build for <code>--target x86_64-unknown-linux-musl</code>.</p> <pre><code> error: failed to run custom build command for `openssl-sys v0.9.58` Caused by: process didn't exit successfully: `/myapp/target/release/build/openssl-sys-3de4fc614d85ad49/build-script-main` (exit code: 101) --- stdout cargo:rustc-cfg=const_fn cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=OPENSSL_LIB_DIR OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_DIR OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=OPENSSL_STATIC cargo:rerun-if-env-changed=OPENSSL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=SYSROOT cargo:rerun-if-env-changed=OPENSSL_STATIC cargo:rerun-if-env-changed=OPENSSL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rustc-link-lib=ssl cargo:rustc-link-lib=gssapi_krb5 cargo:rustc-link-lib=krb5 cargo:rustc-link-lib=com_err cargo:rustc-link-lib=k5crypto cargo:rustc-link-lib=crypto cargo:rustc-link-lib=dl cargo:rustc-link-lib=z cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=OPENSSL_STATIC cargo:rerun-if-env-changed=OPENSSL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-musl cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_musl cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR OPT_LEVEL = Some("3") TARGET = Some("x86_64-unknown-linux-musl") HOST = Some("x86_64-unknown-linux-gnu") CC_x86_64-unknown-linux-musl = None CC_x86_64_unknown_linux_musl = None TARGET_CC = None CC = None CROSS_COMPILE = None CFLAGS_x86_64-unknown-linux-musl = None CFLAGS_x86_64_unknown_linux_musl = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None DEBUG = Some("false") CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2") running: "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c" --- stderr thread 'main' panicked at ' Header expansion error: Error { kind: ToolNotFound, message: "Failed to find tool. Is `musl-gcc` installed?" } Failed to find OpenSSL development headers. You can try fixing this setting the `OPENSSL_DIR` environment variable pointing to your OpenSSL installation or installing OpenSSL headers package specific to your distribution: # On Ubuntu sudo apt-get install libssl-dev # On Arch Linux sudo pacman -S openssl # On Fedora sudo dnf install openssl-devel See rust-openssl README for more information: https://github.com/sfackler/rust-openssl#linux ', /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.58/build/main.rs:140:13 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: build failed </code></pre> <p>I've installed openssl, openssl-devel, group installed "Development Tools", pkg_config and tried a few other things to no avail. I swear this build was working 48 hours ago so not sure if something has changed very recently. Any advice on how to fix this issue?</p><p>该提问来源于开源项目:sfackler/rust-openssl</p></div>
<div><p>The command <code>cargo install cargo-web</code>, after a minute and half of compiling, printed:</p> <pre><code> error: failed to run custom build command for `openssl-sys v0.9.24` process didn't exit successfully: `/tmp/cargo-install.aKdf8gWcEAu5/release/build/openssl-sys-5ee2bfe045b42a7a/build-script-build` (exit code: 101) --- stdout cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR cargo:rerun-if-env-changed=OPENSSL_LIB_DIR cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR cargo:rerun-if-env-changed=OPENSSL_DIR run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit code: 1\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'openssl\' found\n" --- stderr thread 'main' panicked at ' Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set the `OPENSSL_DIR` environment variable for the compilation process. If you're in a situation where you think the directory *should* be found automatically, please open a bug at https://github.com/sfackler/rust-openssl and include information about your system as well as this message. $HOST = x86_64-unknown-linux-gnu $TARGET = x86_64-unknown-linux-gnu openssl-sys = 0.9.24 </code></pre> <p>The command <code>which openssl</code> prints <code>/usr/bin/openssl</code>, and so I tried also the command <code>OPENSSL_DIR=/usr/bin cargo install cargo-web</code>, getting the following output:</p> <pre><code> error: failed to run custom build command for `openssl-sys v0.9.24` process didn't exit successfully: `/tmp/cargo-install.FbQ5fWKqfqMJ/release/build/openssl-sys-5ee2bfe045b42a7a/build-script-build` (exit code: 101) --- stdout cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR cargo:rerun-if-env-changed=OPENSSL_LIB_DIR cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR cargo:rerun-if-env-changed=OPENSSL_DIR --- stderr thread 'main' panicked at 'OpenSSL library directory does not exist: /usr/bin/lib ... </code></pre><p>该提问来源于开源项目:koute/cargo-web</p></div>
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页