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

depend on vendored dbus in order to avoid build failure with libdbus-sys on linux aarch64 target #347

Closed
wants to merge 1 commit into from

Conversation

NuLL3rr0r
Copy link
Contributor

Cross-compiling for Linux AArch64 fails due to libdbus-sys native library dependency. As stated in the dbus-rs compilation guide there are three ways to resolve this issue. The simplest one would be:

dbus = {version = "0.9.7", features = ["vendored"]}

Otherwise, when cross-compiling for AArch64 from a x86-64 Linux host, the user gets:

   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling autocfg v1.1.0
   Compiling libc v0.2.150
   Compiling futures-core v0.3.29
   Compiling futures-sink v0.3.29
   Compiling pin-project-lite v0.2.13
   Compiling futures-channel v0.3.29
   Compiling futures-task v0.3.29
   Compiling futures-util v0.3.29
   Compiling pin-utils v0.1.0
   Compiling futures-io v0.3.29
   Compiling pkg-config v0.3.27
   Compiling memchr v2.6.4
   Compiling serde v1.0.192
   Compiling thiserror v1.0.50
   Compiling parking_lot_core v0.9.9
   Compiling async-trait v0.1.74
   Compiling either v1.9.0
   Compiling scopeguard v1.2.0
   Compiling xml-rs v0.8.19
   Compiling cfg-if v1.0.0
   Compiling smallvec v1.11.2
   Compiling log v0.4.20
   Compiling bytes v1.5.0
   Compiling itertools v0.10.5
   Compiling slab v0.4.9
   Compiling lock_api v0.4.11
   Compiling bitflags v2.4.1
   Compiling hashbrown v0.14.2
   Compiling once_cell v1.18.0
   Compiling uuid v1.5.0
   Compiling static_assertions v1.1.0
   Compiling libdbus-sys v0.2.5
   Compiling quote v1.0.33
error: failed to run custom build command for `libdbus-sys v0.2.5`

Caused by:
  process didn't exit successfully: `/target/release/build/libdbus-sys-a5bd944697d4bc4a/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-changed=build_vendored.rs
  cargo:rerun-if-env-changed=DBUS_1_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
  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-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=DBUS_1_STATIC
  cargo:rerun-if-env-changed=DBUS_1_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_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  pkg_config failed: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig/:" "pkg-config" "--libs" "--cflags" "dbus-1" "dbus-1 >= 1.6"` did not exit successfully: exit status: 1
  error: could not find system library 'dbus-1' required by the 'libdbus-sys' crate

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

  One possible solution is to check whether packages
  'libdbus-1-dev' and 'pkg-config' are installed:
  On Ubuntu:
  sudo apt install libdbus-1-dev pkg-config
  On Fedora:
  sudo dnf install dbus-devel pkgconf-pkg-config

  thread 'main' panicked at /home/mamadou/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libdbus-sys-0.2.5/build.rs:25:9:
  explicit panic
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@NuLL3rr0r NuLL3rr0r changed the base branch from master to dev November 17, 2023 10:51
@tmatilai
Copy link

You can also set the dbus/vendored feature flag in your project. But I think it requires adding the dbus dependency there, too.

Maybe we could have this behind a feature here, too?

@NuLL3rr0r
Copy link
Contributor Author

Yes, I've noticed I can do that too. But, it would be nice to just add btleplug to my Cargo.toml and it works.

Regarding, having this behind a feature that could work as well I think. But, I personally think that might be a bit redundant since adding the above change to my forked btleplug removes the need to set any dependency on dbus in my project's Cargo.toml.

@qwandor
Copy link
Collaborator

qwandor commented Nov 17, 2023

Different people may want to build their project with btleplug in different ways, so I think it's best to add the vendored feature in the Cargo.toml of your binary if you want to do it that way, rather than doing it in btleplug and forcing everyone to use the vendored version. Personally I'd prefer to build it against the relevant system headers in a Docker container, to ensure it gets the right version of everything for the system I'm targeting.

@qwandor qwandor closed this Nov 17, 2023
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

Successfully merging this pull request may close these issues.

3 participants