Arm-Linux Cross compile error

Hello.
I have a problem with cross compile for arm-linux (Beaglebone black).

Build command:
PKG_CONFIG_ALLOW_CROSS=1 cargo build --color=always --target=armv7-unknown-linux-gnueabihf

Error:
= note: /lib/x86_64-linux-gnu/libudev.so*: file not recognized: Nierozpoznawalny format pliku
collect2: error: ld returned 1 exit status
error: aborting due to previous error

Log: https://pastebin.com/LaTyEM4x

How to set cross compiler?
How fix it?

PKG_CONFIG_ALLOW_CROSS=1 breaks things, because pkg-config does not support cross-compilation. pkg-config is a dumb tool that doesn't understand that concept at all, which is why it gets disabled to avoid causing problems.

It's theoretically possible to make pkg-config not break cross-compilation, but it takes a significant amount of work. It's not a matter of changing config, but installing arm-compatible libraries, and creating arm-compatible .pc files for them, and then overriding pkg-config directories.

Try to build everything static/vendored instead.

I'm trying with docker.

mhanusek@EtHanusek:~/work/VersionControl/rs485_example$ cross test --target armv7-unknown-linux-gnueabihf
Unable to find image 'rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.0' locally
armv7-unknown-linux-gnueabihf-0.2.0: Pulling from rustembedded/cross
fe703b657a32: Pulling fs layer 
f9df1fafd224: Pull complete 
a645a4b887f9: Pull complete 
57db7fe0b522: Pull complete 
bfe52882d1e4: Pull complete 
8408d3b87d25: Pull complete 
4e446281d1f6: Pull complete 
de0558bb8359: Pull complete 
dd57a0d4b2c3: Pull complete 
d915dff22ad0: Pull complete 
cf3f0dccb562: Pull complete 
8702ed12f310: Pull complete 
8f9061f891cf: Pull complete 
aabd8567afea: Pull complete 
683b2c71ae03: Pull complete 
e6efe83929cc: Pull complete 
2e41d9742d8b: Pull complete 
80713e213549: Pull complete 
Digest: sha256:3936eeebf83223348a67e778ddb78a253259310ab0559621e617bdefa459cfa3
Status: Downloaded newer image for rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.0
   Compiling libc v0.2.71
   Compiling pkg-config v0.3.17
   Compiling bitflags v1.2.1
   Compiling nix v0.14.1
   Compiling void v1.0.2
   Compiling cfg-if v0.1.10
   Compiling hex-slice v0.1.4
   Compiling libudev-sys v0.1.4
error: failed to run custom build command for `libudev-sys v0.1.4`

Caused by:
  process didn't exit successfully: `/target/debug/build/libudev-sys-fdad08bfef6d059e/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"', /cargo/registry/src/github.com-1ecc6299db9ec823/libudev-sys-0.1.4/build.rs:38:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

How to build static?

This crate has instructions how to build it: https://github.com/dcuddeback/libudev-sys#cross-compiling

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.