Undefined reference to `gpiod_ctxless_set_value'

Hi,

I’m experiencing the issue reported by other users concerning the error undefined reference to `gpiod_ctxless_set_value’ when trying to control GPIOs.

This is my setup:
Verdin iMX8M Plus
Verdin Development Board mit HDMI Adapter
Visual Studio Code 1.79.2
Apollox 2.0.0

I followed the steps described by @lucas_a.tx in the post
https://community.toradex.com/t/cant-seem-to-find-gpiod-h-for-verdin-imx8m-plus-build/19325/15
main.cpp (248 Bytes)
Makefile (1.4 KB)
docker-compose.yml (414 Bytes)
torizonPackages.json (90 Bytes)

Nevertheless I still receive the error `gpiod_ctxless_set_value’.

If you intend to use ApolloX, as you’re using so far:

  • Make sure you followed the steps here to setup ApolloX, until the Creating a new Single Container Project step: GitHub - toradex/torizon-experimental-torizon-ide-v2-docs: VS Code Torizon Integrated Development Environment Documentation (Choose a C++ project instead of the C# the example uses)
  • Add the libgpiod packages to torizonPackages.json, as @hfranco.tx explained before.
  • Add your code to the project. The text editor might complain about gpiod.h not being found. If you did the steps above, ignore the warning.
  • Change Makefile so it has -lgpiod when compiling the relevant source files.
  • Change docker-compose.yaml so that the container has access to the GPIO pins. As an example, adding gpiochip0 will look like:
devices:
  - "/dev/gpiochip0:/dev/gpiochip0"

I would ask your assistance to solve this issue.

Hi @bofrit ,

Just to be sure, the undefined reference error is during the compilation of your project, is this correct?

I took a look at your files and I think I know what the issue is. In the Makefile -lgpiod is in CCFLAGS, but it should be in LDFLAGS instead, as this is the variable being used during the linking stage.

Try doing the above and see if this solves your problem.

Best regards,
Lucas Akira

Hi @lucas_a.tx,

thank you very much for the reply.
The solution you proposed solved the issue.
The GPIO can be now be controlled.

Glad I could help!

Best regards,
Lucas Akira