在交叉编译rust项目时,为' libgpg-error-sys v0.6.0 '运行定制构建命令失败



每当我尝试在运行arch linux的机器上交叉编译我的rust项目时,使用x86_64-unknown-linux-gnu架构的cross,我得到这个错误

$ cross build --target x86_64-unknown-linux-gnu                                                                                                                         
Compiling tracing v0.1.37
Compiling parking_lot_core v0.9.7
Compiling rand_core v0.5.1
Compiling libgpg-error-sys v0.6.0
error: failed to run custom build command for `libgpg-error-sys v0.6.0`
Caused by:
process didn't exit successfully: `/target/debug/build/libgpg-error-sys-49b8c1a22a8cb06e/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=GPG_ERROR_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
Error: PkgConfig(`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "gpg-error" "gpg-error >= 1.12"` did not exit successfully: exit status: 1
error: could not find system library 'gpg-error' required by the 'libgpg-error-sys' crate
--- stderr
Package gpg-error was not found in the pkg-config search path.
Perhaps you should add the directory containing `gpg-error.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gpg-error' found
Package gpg-error was not found in the pkg-config search path.
Perhaps you should add the directory containing `gpg-error.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gpg-error' found
)
warning: build failed, waiting for other jobs to finish...

我有gpgme = "0.11.0"作为我的Cargo.toml文件的依赖

  • 我重新安装了libgpg-error
  • 尝试将pkg-config --path gpg-error的输出添加到PKG_CONFIG_PATH变量中。pkg-config --path gpg-error的输出为/usr/lib/pkgconfig/gpg-error.pc

这个适合我:

sudo apt-get -y update &&安装libgpgme-dev安装libgpg-error-dev

然后重启终端。