Make error: undefined reference to `gpiod_ctxless_get_value' GPIO problem when building release container

Colibri iMX6DL 512MB IT v1.1b
Colibri Evaluation Board
TorizonCore Upstream 5.6.0dev…202202+build21

Hi,

Seems like when I build my application with F5, I get:

> Executing task: make WORKDIR=/workspaces/EmeraBlockEnergyBox/appconfig_0/work/EmeraBlockEnergyBox install <

make: Warning: File 'EmeraBlockEnergyBox' has modification time 0.88 s in the future
installing...
mkdir -p /workspaces/EmeraBlockEnergyBox/appconfig_0/work/EmeraBlockEnergyBox
cp EmeraBlockEnergyBox /workspaces/EmeraBlockEnergyBox/appconfig_0/work/EmeraBlockEnergyBox/
done.

Terminal will be reused by tasks, press any key to close it.

but if I run F1 → Torizon: build release container for this application: I get:

> Executing task: make WORKDIR=/workspaces/EmeraBlockEnergyBox/appconfig_0/work/EmeraBlockEnergyBox install <

arm-linux-gnueabihf-gcc -o EmeraBlockEnergyBox EmeraBlockEnergyBox.o 
/usr/lib/gcc-cross/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/bin/ld: EmeraBlockEnergyBox.o: in function `InputGPIO':
EmeraBlockEnergyBox.c:(.text+0x407be): undefined reference to `gpiod_ctxless_get_value'
/usr/lib/gcc-cross/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/bin/ld: EmeraBlockEnergyBox.o: in function `OutputGPIO':
EmeraBlockEnergyBox.c:(.text+0x4080c): undefined reference to `gpiod_ctxless_set_value'
collect2: error: ld returned 1 exit status
make: *** [Makefile:31: EmeraBlockEnergyBox] Error 1
The terminal process "/bin/bash '-c', 'make WORKDIR=/workspaces/EmeraBlockEnergyBox/appconfig_0/work/EmeraBlockEnergyBox install'" failed to launch (exit code: 2).

Terminal will be reused by tasks, press any key to close it.

As I recall, I needed to install dev packages:
libgpiod-dev:armhf
which was a run-time library which needed to be present on my device.
Is it possible I need to apt-get this into Ubuntu as well in WSL?

Hi @leighjboyd ,

libgpiod-dev:armhf is actually the package needed for the SDK container, the one in your host PC that builds your application. But as you recalled, you also need the runtime library in the container that will be executed on the device. To do this, you need to add libgpiod2 in the extrapackages field.

You don’t need to install these packages in WSL nor anywhere outside of these two containers.

About your error message, that seems to indicate that some functions were not found during compilation. Try adding the flag -lgpiod in your Makefile, which should be similar to this:

DEPS = EmeraBlockEnergyBox.h
OBJ = EmeraBlockEnergyBox.o

%.o : %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)

EmeraBlockEnergyBox: $(OBJ)
	$(CC) -o $@ $^ $(CFLAGS) -lgpiod

install: EmeraBlockEnergyBox
	mkdir -p $(WORKDIR)
	cp EmeraBlockEnergyBox $(WORKDIR)/

clean:
	rm -f *.o
	rm -f EmeraBlockEnergyBox

Hope this makes things clearer for you.

Best regards,
Lucas Akira

Hmmm…

could have sworn I added this in the past, as I remember seeing it in your documentation,
specifically here:

oh well, now it compiles anyways,
thanks again!