Skip to main content
2 of 2
edited tags
Philippos
  • 13.7k
  • 2
  • 42
  • 82

Cross-compile libgpiod library and use it in my program

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!