问题:使用命令cross build --target aarch64-unknown-linux-gnu --release打包报错

...
  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.109


warning: build failed, waiting for other jobs to finish...

原因在于打包的docker镜像缺少libssl-dev

解决方案1 - 构建镜像添加依赖

在项目根目录添加Cross.toml文件,写入如下内容:

[target.aarch64-unknown-linux-gnu]
pre-build = [
    "dpkg --add-architecture arm64",
    "apt-get update",
    "apt-get install -y libssl-dev:arm64"
]

这个方法要求你目标部署机器拥有libssl依赖,如果无法满足要求,也可以使用解决方案2

解决方案2 - 静态链接OpenSSL