Cross compile for ARM

Hello.
I have a problem with cross-compile for arm-linux pratform.

script build.sh :

#!/bin/bash

SYSROOT=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux

shopt -s expand_aliases
source /opt/etos/3.1.1/environment-setup-armv7at2hf-neon-etos-linux-gnueabi

export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/pkgconfig
export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
export PKG_CONFIG_ALLOW_CROSS=1

cargo build

Error:

error: failed to run custom build command for `libudev-sys v0.1.4`

Caused by:
  process didn't exit successfully: `/home/gitlab-runner/builds/iWLgNQq6/0/ekm3/drivers/transparent/target/debug/build/libudev-sys-7b970b314f869522/build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBUDEV_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBUDEV_STATIC
  cargo:rerun-if-env-changed=LIBUDEV_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 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"libudev\"` did not exit successfully: exit code: 1\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"', /home/gitlab-runner/.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...
error: build failed

printenv:

OE_QMAKE_INCDIR_QT=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi/usr/include
AS=arm-etos-linux-gnueabi-as 
LDFLAGS=-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
AR=arm-etos-linux-gnueabi-ar
OECORE_TARGET_SYSROOT=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
OE_QMAKE_QDBUSXML2CPP=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/qdbusxml2cpp
TARGET_PREFIX=arm-etos-linux-gnueabi-
M4=m4
OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=
OE_CMAKE_TOOLCHAIN_FILE=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/share/cmake/OEToolchainConfig.cmake
SHELL=/bin/bash
TERM=xterm-256color
NM=arm-etos-linux-gnueabi-nm
OE_QMAKE_CXX=arm-etos-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
OECORE_DISTRO_VERSION=3.1.1
CPPFLAGS=
OE_QMAKE_CXXFLAGS= -O2 -pipe -g -feliminate-unused-debug-types 
OECORE_SDK_VERSION=3.1.1
GDB=arm-etos-linux-gnueabi-gdb
USER=gitlab-runner
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
SUDO_USER=mhanusek
SUDO_UID=1005
PKG_CONFIG_SYSROOT_DIR=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
CXXFLAGS= -O2 -pipe -g -feliminate-unused-debug-types 
CONFIG_SITE=/opt/etos/3.1.1/site-config-armv7at2hf-neon-etos-linux-gnueabi
USERNAME=root
OE_QMAKE_UIC=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/uic
OE_QMAKE_RCC=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/rcc
CPP=arm-etos-linux-gnueabi-gcc -E  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
OE_QMAKE_AR=arm-etos-linux-gnueabi-ar
MAIL=/var/mail/gitlab-runner
PATH=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/sbin:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/bin:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/sbin:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/../x86_64-etossdk-linux/bin:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/arm-etos-linux-gnueabi:/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/arm-etos-linux-musl:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
OE_QMAKE_PATH_HOST_BINS=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin
LD=arm-etos-linux-gnueabi-ld  --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
OE_QMAKE_STRIP=arm-etos-linux-gnueabi-strip
PWD=/home/gitlab-runner/builds/iWLgNQq6/0/ekm3/drivers/transparent
STRIP=arm-etos-linux-gnueabi-strip
LANG=pl_PL.UTF-8
OE_QMAKE_LINK=arm-etos-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
QMAKESPEC=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi/usr/lib/mkspecs/linux-oe-g++
QT_CONF_PATH=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/qt.conf
OECORE_TARGET_ARCH=arm
OECORE_NATIVE_SYSROOT=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux
CONFIGURE_FLAGS=--target=arm-etos-linux-gnueabi --host=arm-etos-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
OE_QMAKE_QT_CONFIG=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi/usr/lib/mkspecs/qconfig.pri
OE_QMAKE_CC=arm-etos-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
KCFLAGS=--sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
CXX=arm-etos-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
OBJCOPY=arm-etos-linux-gnueabi-objcopy
OECORE_TARGET_OS=linux-gnueabi
OECORE_BASELIB=lib
SHLVL=1
SUDO_COMMAND=/bin/su gitlab-runner
HOME=/home/gitlab-runner
OPENSSL_CONF=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/lib/ssl-1.1/openssl.cnf
CFLAGS= -O2 -pipe -g -feliminate-unused-debug-types 
LOGNAME=gitlab-runner
OE_QMAKE_MOC=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/moc
OE_QMAKE_QDBUSCPP2XML=/opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/bin/qdbuscpp2xml
OECORE_ACLOCAL_OPTS=-I /opt/etos/3.1.1/sysroots/x86_64-etossdk-linux/usr/share/aclocal
PKG_CONFIG_PATH=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi/usr/lib/pkgconfig:/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi/usr/share/pkgconfig
LESSOPEN=| /usr/bin/lesspipe %s
ARCH=arm
RANLIB=arm-etos-linux-gnueabi-ranlib
OE_QMAKE_CFLAGS= -O2 -pipe -g -feliminate-unused-debug-types 
CROSS_COMPILE=arm-etos-linux-gnueabi-
CC=arm-etos-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
SUDO_GID=1005
READELF=arm-etos-linux-gnueabi-readelf
OE_QMAKE_LIBDIR_QT=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi/usr/lib
OBJDUMP=arm-etos-linux-gnueabi-objdump
LESSCLOSE=/usr/bin/lesspipe %s %s
OE_QMAKE_LDFLAGS=-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
SDKTARGETSYSROOT=/opt/etos/3.1.1/sysroots/armv7at2hf-neon-etos-linux-gnueabi
_=/usr/bin/printenv

You need to install the libudev-dev package for arm.

1 Like

That looks like an x86_64 sysroot. You need to set sysroot to an ARM one.