Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling to x86_64-unknown-linux-gnu with alsa using libudev dependency #1437

Open
cBournhonesque opened this issue Feb 5, 2024 · 2 comments

Comments

@cBournhonesque
Copy link

My compilation fails:

called `Result::unwrap()` on an `Err` value: "`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=\"1\" PKG_CONFIG_ALLOW_SYSTEM_LIBS=\"1\" \"pkg-config\" \"--libs\" \"--cflags\" \"libudev\"` did not exit successfully: exit status: 1\nerror: could not find system library 'libudev' required by the 'libudev-sys' crate\n\n--- stderr\nPackage libudev was not found in the pkg-config search path.\nPerhaps you should add the directory containing `libudev.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'libudev' found\n"

even though I added this to my Cross.toml:

[target.x86_64-unknown-linux-gnu]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get install --assume-yes pkg-config:$CROSS_DEB_ARCH libssl-dev:$CROSS_DEB_ARCH ca-certificates:$CROSS_DEB_ARCH libasound2-dev:$CROSS_DEB_ARCH libpulse-dev:$CROSS_DEB_ARCH libdbus-1-dev:$CROSS_DEB_ARCH portaudio19-dev:$CROSS_DEB_ARCH libudev-dev:$CROSS_DEB_ARCH"
]

My run command is cross build --release --target x86_64-unknown-linux-gnu.

I searched online and it looks like I might be missing from complicated linker env variables?

@Emilgardis Emilgardis changed the title Compiling from arm64 to x86_64 with alsa Compiling to x86_64-unknown-linux-gnu with alsa using libudev dependency Feb 6, 2024
@Emilgardis
Copy link
Member

I'm not able to replicate this, neither with v0.2.5 or using main. Can you post the entire build log

here's my try at reproducing it

cargo init
cargo add libudev-sys
# Cross.toml
[target.x86_64-unknown-linux-gnu]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    """apt-get update && apt-get install --assume-yes \
        pkg-config:$CROSS_DEB_ARCH \
        libssl-dev:$CROSS_DEB_ARCH \
        ca-certificates:$CROSS_DEB_ARCH \
        libasound2-dev:$CROSS_DEB_ARCH \
        libpulse-dev:$CROSS_DEB_ARCH \
        libdbus-1-dev:$CROSS_DEB_ARCH \
        portaudio19-dev:$CROSS_DEB_ARCH \
        libudev-dev:$CROSS_DEB_ARCH \
    """
]
❯ cross build --release --target x86_64-unknown-linux-gnu
   Compiling pkg-config v0.3.29
   Compiling libc v0.2.153
   Compiling libudev-sys v0.1.4
   Compiling libudev-test v0.1.0 (/project)
    Finished release [optimized] target(s) in 44.24s

@cBournhonesque
Copy link
Author

Hm i'm not too sure why but the error I get now is related to alsa:

error: failed to run custom build command for `alsa-sys v0.3.1`

Caused by:
  process didn't exit successfully: `/target/release/build/alsa-sys-6d9c1bff4963f07a/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ALSA_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=ALSA_STATIC
  cargo:rerun-if-env-changed=ALSA_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  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
  thread 'main' panicked at /Users/cbournhonesque/dev/rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alsa-sys-0.3.1/build.rs:13:18:
  `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "alsa"` did not exit successfully: exit status: 1
  error: could not find system library 'alsa' required by the 'alsa-sys' crate

  --- stderr
  Package alsa was not found in the pkg-config search path.
  Perhaps you should add the directory containing `alsa.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'alsa' found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants