Skip to contentSkip to conversation

Missing -lgpiod during linking an application that uses libgpiod

DISCUSSION Javier Casas Marín 1 participant 2 messages Nov 4, 2023

lore
Share & tools
lore
#0 lore raw

Hi,

I’m building a Qt application to controls a few GPIOs so, in my recipe, I add libgpiod to the DEPENDS variable, but even then the –lgpiod is missing in the linking stage and the build fails with several ‘undefined reference’ errors to the gpiod functions:

| /build/tmp/work/cortexa53-crypto-imx-ked-linux/testapp/0.1-r0/recipe-sysroot-native/usr/bin/aarch64-ked-linux/../../libexec/aarch64-ked-linux/gcc/aarch64-ked-linux/11.4.0/ld: /usr/src/debug/ testapp /0.1-r0/build/../m4/inou.c:48: undefined reference to `gpiod_chip_get_line'

| /build/tmp/work/cortexa53-crypto-imx-ked-linux/ testapp /0.1-r0/recipe-sysroot-native/usr/bin/aarch64-ked-linux/../../libexec/aarch64-ked-linux/gcc/aarch64-ked-linux/11.4.0/ld: /usr/src/debug/ testapp /0.1-r0/build/../m4/inou.c:55: undefined reference to `gpiod_line_request_output'

| /build/tmp/work/cortexa53-crypto-imx-ked-linux/ testapp /0.1-r0/recipe-sysroot-native/usr/bin/aarch64-ked-linux/../../libexec/aarch64-ked-linux/gcc/aarch64-ked-linux/11.4.0/ld: /usr/src/debug/ testapp /0.1-r0/build/../m4/inou.c:61: undefined reference to `gpiod_line_set_value'

| /build/tmp/work/cortexa53-crypto-imx-ked-linux/ testapp /0.1-r0/recipe-sysroot-native/usr/bin/aarch64-ked-linux/../../libexec/aarch64-ked-linux/gcc/aarch64-ked-linux/11.4.0/ld: /usr/src/debug/ testapp /0.1-r0/build/../m4/inou.c:67: undefined reference to `gpiod_line_release'

| /build/tmp/work/cortexa53-crypto-imx-ked-linux/ testapp /0.1-r0/recipe-sysroot-native/usr/bin/aarch64-ked-linux/../../libexec/aarch64-ked-linux/gcc/aarch64-ked-linux/11.4.0/ld: /usr/src/debug/ testapp /0.1-r0/build/../m4/inou.c:69: undefined reference to `gpiod_chip_close'

This is my recipe:

SUMMARY = "GPIO QT TEST APPLICATION"

DESCRIPTION = "GPIO user interface build with QT"

LICENSE = "GPLv2"

LIC_FILES_CHKSUM = " file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 ( file://$%7bCOREBASE%7d/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 ) "

SRC_URI = "<source files added here>"

DEPENDS += "qtbase qtdeclarative qtmultimedia qtwebengine *libgpiod* "

RDEPENDS:${PN} += "qtxmlpatterns qtdeclarative-qmlplugins qtbase-plugins ttf-dejavu-sans qtquickcontrols qtquickcontrols2 qtfreevirtualkeyboard "

S = "${WORKDIR}"

do_install:append () {

install -d ${D}${bindir}

install -m 0775 qt_testgpio ${D}${bindir}

}

FILES:${PN} += "${bindir}/qt_testgpio"

FILES:${PN} += "/opt/*"

inherit qmake5

What am I missing? Shouldn’t the inclusion of libpgiod library to the DEPENDS variable result in the addition of –lgpiod to the link command? I tried to add LDFLAGS:append = “ –lgpiod” but it didn’t solve the problem.

Any help will be appreciated.

Kind regards,

Javi

#1 lore raw

I solved the issue. It turned out to be not a yocto but a Qt problem. The Makefile used to build the application is autogenerated by qmake so you have to include LIBS += -lgpiod in order to add the library in the linking stage.

I was looking in the wrong place!

Sorry for the noise

javi