Imx7: error while loading shared libraries: libgpiod.so.2: cannot open shared object file: No such file or directory

Hello there
I set the eclipse IDE with the with the toolchain5.7.0 for yocto

environment-setup-armv7at2hf-neon-tdx-linux-gnueabi

The goal is work with the GPIO and I try to compile the sketch
https://github.com/toradex/torizon-samples/tree/bullseye/gpio/c
(even if a snippet for torizon-samples)

The code is compiled properly without error but when I move the executable file on coilibri module
it shows the above mentioned error.
It seems that a wrong platform library (e.g. x64?) is used by the compiler

Does somebody faced up this issue?
Thanks

You may check architecture of your binary file with
readelf -h your_binary

Eclipse seems ignoring environment-setup* script.

For Yocto SDK you may follow instructions like these. Instead of Yocto ADT plugin for older? luna
Eclipse here http://downloads.yoctoproject.org/releases/eclipse-plugin/1.8/luna
you may use newer Yocto SDK plugins. The rest of setup is the same like in instructions. I used this plugin url http://downloads.yoctoproject.org/releases/eclipse-plugin/2.6.1/oxygen/ with Eclipse 2022-06.

Hi Edward first of all thank you for your kind feedback.
The architecture get by readelf on my comiled indicates “Machine: ARM”

Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x5dd
  Start of program headers:          52 (bytes into file)
  Start of section headers:          10432 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         37
  Section header string table index: 36

it seems ok.
Anyway I try to follow the NXP linked indications:
I currently work on last release of BPS which is 5.6.0 and the toolchain created for IMX7 is
/opt/tdx-xwayland/5.7.0

So I install the plugin 2.6.1 as you mentioned
than create a new YOCTO project SDK autools with GNU autotools toolchain setting in the preferences
Toolchain Root Location

/opt/tdx-xwayland/5.7.0

Sysroot Location

/opt/tdx-xwayland/5.7.0/sysroots/armv7at2hf-neon-tdx-linux-gnueabi

Target architecture is the armv7at2hf-neon-tdx-linux-gnueabi
Than called “Reconfigure the project”
and try to build but it arises errors due these issues:
Missing PROG arm-tdx-linux-gnueabi-dlltool
Missing PROG arm-tdx-linux-gnueabi-mt
Missing PROG dlltool

What I did wrong?

Hm, yes, readelf reports valid imx7 image. In my case something makes Eclipse ignoring env settings from environment-setup-*.
Perhaps libgpiod.so isn’t included in your image. I think inclusion of packagegroup-tdx-cli in IMAGE_INSTALL makes libgpio installed. It is included by default in minimal image.

Regarding Yocto SDK setting, I’m puzzled again. For me it worked from from first try. Here’s screenshot from Eclipse->Window->preferences with sdk installed to ~/edward/tdx-sdk:

Did you check libgpiod is present on root FS?

~# ls /usr/lib/libgp*
/usr/lib/libgpiod.so.2         /usr/lib/libgpiodcxx.so.1
/usr/lib/libgpiod.so.2.1.3     /usr/lib/libgpiodcxx.so.1.0.4

The settings is ok
however I cant’ compile a snippet managing GPIO with this method (eclipse plug in)

#include <gpiod.h> 

is declarated without error but methods are not reconigned
i.e. gpiod_ctxless_find_line(…)

and another strange thing is that the project load x86_64 libraries (??)
Immagine 2022-09-02 160822

The previous settings works however thanks to your suggestion I found out
that libgpiod.so.2 is not present into /usr/lib/ is not present on the rootfs indeed!

As you mentioned it is (should be) included by default in minimal image

Could you explain me better about

I think inclusion of packagegroup-tdx-cli in IMAGE_INSTALL makes libgpio installed "

How do it exactly?

First of all regarding SDK and linking to static libgpiod.a.

  1. Your build/conf/local.conf should include, else building SDK won’t populate *.a files.
    SDKIMAGE_FEATURES = “dev-pkgs dbg-pkgs staticdev-pkgs”

  2. Yet another “time saver” from Yocto, you need to ./configure --enable-static when building libgpiod. To do so you may add in your appropriate layer folder libgpiod_%.bbappend with this.
    EXTRA_OECONF_append = " --enable-static"
    Perhaps it can be done via some conf file, I’m not sure.

  3. re-bitbake populate_sdk and reinstall SDK.

  4. You need to add in your project settings to LDFLAGS -lgpiod here
    image

scroll to LDFLAGS string and add -lgpiod.

Of course libgpiod should be in the list of packages to populate.

Regarding IMAGE_INSTALL. Well, somehow you build your custom image indeed, isn’t it? Your image.bb file should include string IMAGE_INSTALL, which tells Yocto which packages to populate to target. For example the same setting for Toradex minimal image is here:
layers/meta-toradex-demos/recipes-images/images/tdx-reference-minimal-image.bb

You may build this image with bitbake tdx-reference-minimal-image and this image must include ligpiod*.so

Edit: missing step 3

Edit2: Regarding x64-x86 in Eclipse. I see the same, but image build correctly with includes from SDK. I think Yocto plugin doesn’t provide Eclipse parses them from right include folders.

1 Like

Thanks Edward!
Solved!