rust-cross / rust-musl-cross

Docker images for compiling static Rust binaries using musl-cross
MIT License
621 stars 69 forks source link

pkg-config has not been configured for cross-compilation (external sys dependencies) #33

Closed gustafla closed 3 years ago

gustafla commented 3 years ago

Hi, I'm sorry if this is not the right place to ask, but my application depends on libpulse-sys and causes the following error when I try to build it in the container. I understand that getting host system's libraries to link is not trivial, but I wonder if you can just compile and provide a cross-compiling pkg-config?

The following warnings were emitted during compilation:

warning: pkg-config has not been configured to support cross-compilation.

error: failed to run custom build command for `libpulse-sys v1.18.0`

Caused by:
  process didn't exit successfully: `/home/rust/src/target/release/build/libpulse-sys-0b539a63b06ecfcd/build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=LIBPULSE_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_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_x86_64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_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_x86_64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=LIBPULSE_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_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_x86_64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_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_x86_64-unknown-linux-musl
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_musl
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=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.
warning: build failed, waiting for other jobs to finish...
error: build failed
messense commented 3 years ago

I'm happy to accept a PR implement it.

gustafla commented 3 years ago

Toolchains and docker are not my thing but I can try and have a look! Thank you for the reply

gustafla commented 3 years ago

Nevermind, turns out I can just set PKG_CONFIG_SYSROOT_DIR=/ and straight up build on my host with cargo build --target x86_64-unknown-linux-musl when I have that target installed.