[英]Error build Rust for linux in macos - Openssl
Trying to compile for linux from a mac throws this error, I have openssl and pkg-config installed from brew .尝试从 Mac 编译 linux 会引发此错误,我从brew安装了openssl和pkg-config 。
And in the file ~/.cargo/config I have this configuration.在文件 ~/.cargo/config 我有这个配置。
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
Error:错误:
error: failed to run custom build command for `openssl-sys v0.9.72`
Caused by:
process didn't exit successfully: `/Users/Proyect/cvm/target/release/build/openssl-sys-66182f9fe15cdddc/build-script-main` (exit status: 101)
run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit status: 1\nerror: could not find system library 'openssl' required by the 'openssl-sys' crate\n\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.
Make sure you also have the development packages of openssl installed.
For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
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-apple-darwin
$TARGET = x86_64-unknown-linux-gnu
openssl-sys = 0.9.72
', /Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.72/build/find_normal.rs:180:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
The error message contains three possible solutions:错误消息包含三种可能的解决方案:
First make sure it is really installed including for development (which is what you need if you want to compile code against openssl):首先确保它确实已安装,包括用于开发(如果您想针对 openssl 编译代码,这就是您所需要的):
Make sure you also have the development packages of openssl installed.确保您还安装了 openssl 的开发包。 For example,
libssl-dev
on Ubuntu oropenssl-devel
on Fedora.例如,Ubuntu 上libssl-dev
或 Fedora 上openssl-devel
。
If it is already really installed, then it could not be found.如果它已经真正安装了,那么它就找不到了。 This can be fixed by adding the directory containing `openssl.pc' to the PKG_CONFIG_PATH environment variable:这可以通过将包含 `openssl.pc' 的目录添加到 PKG_CONFIG_PATH 环境变量来解决:
Package openssl was not found in the pkg-config search path.在 pkg-config 搜索路径中找不到 Package openssl。 Perhaps you should add the directory containing `openssl.pc' to the PKG_CONFIG_PATH environment variable.也许您应该将包含 `openssl.pc' 的目录添加到 PKG_CONFIG_PATH 环境变量中。
Or by setting the OPENSSL_DIR
to point to where the openssl code is on your system:或者通过将OPENSSL_DIR
设置为指向 openssl 代码在您的系统上的位置:
Could not find directory of OpenSSL installation, and this
-sys
crate cannot proceed without this knowledge.找不到 OpenSSL 安装目录,如果没有这些知识,这个-sys
crate 将无法继续。 If OpenSSL is installed and this crate had trouble finding it, you can set theOPENSSL_DIR
environment variable for the compilation process.如果安装了 OpenSSL 并且此 crate 无法找到它,您可以为编译过程设置OPENSSL_DIR
环境变量。
try add尝试添加
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
to your Cargo.toml到您的 Cargo.toml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.