Arm-Linux Cross compile error

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

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

Log: cross build libudev error -

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 simple 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 setting a variable, but you need to actually install arm-compatible libraries, get arm-compatible .pc files for them, and then override pkg-config directories (setting so-called sysroot) to make it see only the arm-specific versions.

Try to build everything static/vendored instead.

I did solved this with docker.


FROM rustembedded/cross:arm-unknown-linux-gnueabihf

RUN apt-get update && apt-get install -y --no-install-recommends apt-utils

RUN dpkg --add-architecture armhf && \
    apt-get update && \
    apt-get install --assume-yes libpthread-stubs0-dev:armhf && \
    apt-get install --assume-yes libudev-dev:armhf && \
    apt-get install --assume-yes libudev1:armhf && \
    apt-get install --assume-yes pkg-config

On docker container :

curl --proto '=https' --tlsv1.2 -sSf | sh
rustup target add arm-unknown-linux-gnueabihf
root@aa6d9e933b0f:/home# ls /usr/lib/arm-linux-gnueabihf/pkgconfig
libudev.pc  pthread-stubs.pc



export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig

cargo build --target=arm-unknown-linux-gnueabihf

This crate has instructions how to build it: GitHub - dcuddeback/libudev-sys: FFI bindings to libudev

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.