I am trying to cross-compile a program with the "gpiod" library.

My host pc has Ubuntu 18.04 and the target platform I am cross-compiling for is a Board with IMX8X SOM.

I found source code at https://variwiki.com/index.php?title=MX8_GPIO&release=RELEASE_DUNFELL_V1.3_VAR-SOM-MX8X and I wanted to compile it, following the paragraph "2.2 libgpiod C Application". The OS used in my board is the "dunfell" distro compiled with Yocto. The cross-compiler I am using is also created as sdk withing the Yocto environments (aarch64-fslc-linux-gcc).

When I compiled, I firstly obtained

"fatal error: gpiod.h: No such file or directory"

So, this library is not included by default in the provided toolchain. So I tried to install the (cross)library in my pc, following the instructions at https://www.beyondlogic.org/an-introduction-to-chardev-gpio-and-libgpiod-on-the-raspberry-pi/ , but it did not work. The second error I get is

/opt/fslc-wayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/libexec/aarch64-fslc-linux/gcc/aarch64-fslc-linux/9.3.0/real-ld: cannot find -lgpiod
collect2: error: ld returned 1 exit status

These are my compilation flags:

CFLAGS = -Wall -I$(INCLUDE) --sysroot=${SDKTARGETSYSROOT} -Og -lgpiod

I am new to this kind of issues and I hope I am making trivial mistakes. Thanks in advance if someone is able to help!


2 Answers 2


Under android system, please use android ndk

export PATH=$PATH:/home/semilog/Android/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin

./autogen.sh --enable-tools=yes --host=armv8 CC=aarch64-linux-android24-clang --with-sysroot=/home/semilog/Android/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/semilog/work/kernel/out

Remove program_invocation_name from source code manually first.

make all install

  • Please don't post multiple nearly-identical answers to the same question.  Edit your other post to include both solutions. Jun 24, 2022 at 19:21
export PATH=$PATH:/opt/arm-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/

comment AC_FUNC_MALLOC from configure.ac

./autogen.sh --enable-tools=yes --host=armv8 CC=aarch64-linux-gnu-gcc --prefix=/home/semilog/work/kernel/out

make all install

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .