Stefan B.
Stefan B.

Reputation: 384

Yocto recipe to compile C++ program with usb.h include

I would like to compile a c++ program in my yocto toolchain. For this, I added a new recipe that should compile the program and install it into the image.

My issue is that I have to include some kernel headers like `usb.h``

recipe.bb

SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI += "file://dcdc-nuc.h \
           file://dcdc-nuc.cpp \
           file://dcdc-nuc-console.cpp \
           "

S = "${WORKDIR}"

TARGET_CC_ARCH += "${LDFLAGS}"

do_compile() {
         ${CXX}  ${BUILD_CXXFLAGS}  dcdc-nuc-console.cpp -o dcdc-nuc
}

do_install() {
         install -d ${D}${bindir}
         install -m 0755 dcdc-nuc ${D}${bindir}
}

Current message


| In file included from dcdc-nuc-console.cpp:23:
| dcdc-nuc.h:23:10: fatal error: linux/usb.h: No such file or directory
|    23 | #include <usb.h>
|       |          ^~~~~~~
| compilation terminated.
| WARNING: exit code 1 from a shell command.

I know that I have to make the compile aware of the kernel headers but I'm not able to find any hint on how to do this. Thanks for all the help in advance!

Upvotes: 2

Views: 979

Answers (1)

Ricardo Vargas
Ricardo Vargas

Reputation: 46

I believe you need to add libusb as a dependence to your recipe.

Add the following line to your recipe:

DEPENDS = "libusb"

Upvotes: 3

Related Questions