在macos中为Linux构建Rust时出错- Openssl

00jrzges  于 2023-01-21  发布在  Mac
关注(0)|答案(3)|浏览(600)

尝试从mac编译linux会抛出这个错误,我从brew安装了opensslpkg-config
在文件~/.cargo/config中我有这样的配置。

[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

错误:

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
6tdlim6h

6tdlim6h1#

错误消息包含三种可能的解决方案:
首先确保它已经安装好了,包括用于开发(如果你想编译openssl代码,这是你需要的):
确保你也安装了openssl的开发包,例如Ubuntu上的libssl-dev或Fedora上的openssl-devel
如果已经安装了,那么就找不到它了。这可以通过在PKG_CONFIG_PATH环境变量中添加包含'openssl.pc'的目录来解决:
在pkg-config搜索路径中找不到openssl包。也许您应该将包含“openssl.pc”的目录添加到PKG_CONFIG_PATH环境变量中。
或者通过设置OPENSSL_DIR指向openssl代码在系统中的位置:
找不到OpenSSL安装目录,并且此-sys机箱无法在不了解此信息的情况下继续。如果OpenSSL已安装,并且此机箱在查找时遇到问题,则可以为编译过程设置OPENSSL_DIR环境变量。

ct3nt3jp

ct3nt3jp2#

经过大量的尝试和尝试,我找到了这个script,编译为linux从mac。
您只需要将它复制到项目的根文件夹并运行它。

hyrbngr7

hyrbngr73#

尝试添加

[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

你的货物。toml

相关问题