首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在macos - Openssl中为linux构建Rust错误

在macos - Openssl中为linux构建Rust错误
EN

Stack Overflow用户
提问于 2022-03-02 03:55:53
回答 3查看 3.4K关注 0票数 3

试图从mac编译linux会引发此错误,我从brew安装了opensslpkg-config

在文件~/..cargo/config中,我有这样的配置。

代码语言:javascript
运行
复制
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

错误:

代码语言:javascript
运行
复制
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
EN

回答 3

Stack Overflow用户

发布于 2022-03-02 17:53:14

错误消息包含三种可能的解决方案:

首先,确保它是真正安装的,包括用于开发的(如果您想要针对openssl编译代码,这就是您所需要的):

确保还安装了openssl的开发包。例如,Ubuntu上的libssl-dev或Fedora上的openssl-devel

如果它已经真正安装,那么就找不到它。可以通过将包含`openssl.pc‘的目录添加到PKG_CONFIG_PATH环境变量中来解决这个问题:

在pkg-config搜索路径中找不到包openssl。也许您应该将包含`openssl.pc‘的目录添加到PKG_CONFIG_PATH环境变量中。

或者将OPENSSL_DIR设置为指向系统上openssl代码的位置:

无法找到OpenSSL安装目录,此-sys机箱无法在没有此知识的情况下继续进行。如果安装了OpenSSL,并且这个机箱找不到它,您可以为编译过程设置OPENSSL_DIR环境变量。

票数 4
EN

Stack Overflow用户

发布于 2022-03-03 14:15:04

经过大量的尝试和尝试,我找到了这个从mac编译linux的脚本

您只需将其复制到项目的根文件夹并运行它即可。

票数 0
EN

Stack Overflow用户

发布于 2022-09-14 05:23:51

试着添加

代码语言:javascript
运行
复制
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

给你的Cargo.toml

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71317287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档