Aarch64-unknown-linux-musl | fail with libssl-dev | how to crosscompile?

Hello,
using a Debian 12 on x86_64.
Wanna crosscompile for: aarch64-unknown-linux-musl

Which packages I need to install to be able to compile

error: failed to run custom build command for `openssl-sys v0.9.101`

Caused by:
  process didn't exit successfully: `/home/developer/rust/weather/target/release/build/openssl-sys-c0a5fbbcbd9f5a89/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR
  AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR
  AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR
  AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

  --- stderr
  thread 'main' panicked at /home/developer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.101/build/find_normal.rs:190:5:


  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-musl
  openssl-sys = 0.9.101


  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Had a simular issue with: aarch64-unknown-linux-gnu
there was the Solution: sudo apt-get install libssl-dev:arm64

But what do I need for: aarch64-unknown-linux-musl ?

Did you try sudo apt-get install libssl-dev:aarch64?

yes but....

$ sudo apt-get install libssl-dev:aarch64
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libssl-dev:aarch64

source.list

deb-src [arch=amd64,i386,armel,armhf,aarch64,arm64,musl] Index of /debian bookworm-updates main contrib

$ dpkg -l | grep libssl
ii  libssl-dev:amd64                                      3.0.11-1~deb12u2                        amd64        Secure Sockets Layer toolkit - development files
ii  libssl-dev:arm64                                      3.0.11-1~deb12u2                        arm64        Secure Sockets Layer toolkit - development files
ii  libssl-dev:armhf                                      3.0.11-1~deb12u2                        armhf        Secure Sockets Layer toolkit - development files
ii  libssl-dev:i386                                       3.0.11-1~deb12u2                        i386         Secure Sockets Layer toolkit - development files
ii  libssl-dev:ppc64el                                    3.0.11-1~deb12u2                        ppc64el      Secure Sockets Layer toolkit - development files
ii  libssl1.1:amd64                                       1.1.1n-0+deb11u5                        amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl3:amd64                                         3.0.11-1~deb12u2                        amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl3:arm64                                         3.0.11-1~deb12u2                        arm64        Secure Sockets Layer toolkit - shared libraries
ii  libssl3:armhf                                         3.0.11-1~deb12u2                        armhf        Secure Sockets Layer toolkit - shared libraries
ii  libssl3:i386                                          3.0.11-1~deb12u2                        i386         Secure Sockets Layer toolkit - shared libraries
ii  libssl3:ppc64el                                       3.0.11-1~deb12u2                        ppc64el      Secure Sockets Layer toolkit - shared libraries

It looks like it’s not supported unfortunately.

Debian is a glibc based distro, so all dynamic libraries are only provided in a version compiled against glibc. The easiest solution is likely compiling inside a docker container of a musl based distro like alpine linux.

thank you

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.