I am new to rust and trying to do cross compilation. However while doing that I am getting an error error: failed to run custom build command for libudev-sys v0.1.4 . I tried following the solution at
However, I was not able to resolve the issue. I am using Ubuntu 20.04 and want to cross compile for raspberry pi.
It would be great if someone can provide me an insight to what should I include in the
build script.
#!/bin/sh
SYSROOT=/build/root
export PKG_CONFIG_DIR=
export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
export PKG_CONFIG_ALLOW_CROSS=1
# tell pkg-config where to find libudev.pc
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
# tell cargo to link with an armhf compatible linker
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
cargo build --release --target=armv7-unknown-linux-gnueabihf
error: failed to run custom build command for libudev-sys v0.1.4
--- stderr
thread 'main' panicked at 'called Result::unwrap() on an Err value: "pkg-config has not been configured to support cross-compilation.\n\nInstall a sysroot for the target platform and configure it via\nPKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\ncross-compiling wrapper for pkg-config and set it via\nPKG_CONFIG environment variable."', /home/akumar/.cargo/registry/src/github.com-1ecc6299db9ec823/libudev-sys-0.1.4/build.rs:38:41
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Is the error you get a result of following the instructions in the link you have given? Or do you get the error when you normally do cargo build?
Because as far as I can tell, the instructions in the issue you have linked should solve the problem.
Greetings,
I am new to rust and I think I am messing while doing the last step, can you please guide me that do I need to just copy paste this or need to edit ? Like should it be like export PKG_CONFIG_DIR=
#!/bin/sh
SYSROOT=/build/root
export PKG_CONFIG_DIR=
export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
export PKG_CONFIG_ALLOW_CROSS=1
# tell pkg-config where to find libudev.pc
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
# tell cargo to link with an armhf compatible linker
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
cargo build --release --target=armv7-unknown-linux-gnueabihf