我正在尝试交叉编译使用交叉的Rust项目
我得到了一个错误,我希望通过设置环境变量RUST_BACKTRACE=1来跟踪进程。
但我不知道如何在使用交叉时做到这一点。
编辑
我使用的是命令cross build --target aarch64-unknown-linux-gnu
这是我的“cross.toml”内容
[target.aarch64-unknown-linux-gnu]
openssl-sys = "0.9.76"
[build.env]
passthrough = [
"RUST_BACKTRACE",
"RUST_LOG",
"TRAVIS",
]
[target.aarch64-unknown-linux-gnu.env]
passthrough = [
"RUST_DEBUG",
]在试图编译时,我得到了以下错误
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-unknown-linux-gnu
$TARGET = aarch64-unknown-linux-gnu
openssl-sys = 0.9.76
', /cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.76/build/find_normal.rs:191:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace发布于 2022-10-23 10:21:25
在passthrough中使用Cross.toml只是传递本地环境变量。因此,在您的示例中,它按预期工作,但是它没有按您的要求工作,原因是没有设置RUST_BACKTRACE变量。
在Linux/Unix (mac)中,您可以通过编写echo $RUST_BACKTRACE和编写RUST_BACKTRACE=1临时设置环境的值。
因此,为了在交叉中设置变量,可以在运行命令时设置RUST_BACKTRACE,如下所示:
RUST_BACKTRACE=1 cross build --target aarch64-unknown-linux-gnu也可以在Cross.toml配置中直接设置值,如下所示:
[target.aarch64-unknown-linux-gnu]
openssl-sys = "0.9.76"
[build.env]
passthrough = [
"RUST_BACKTRACE=1",
"RUST_LOG",
"TRAVIS",
]
[target.aarch64-unknown-linux-gnu.env]
passthrough = [
"RUST_DEBUG",
]https://stackoverflow.com/questions/74155695
复制相似问题