使用 usb.h 编译 C++ 程序的 Yocto 配方包括

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

我想在我的 yocto 工具链中编译一个 c++ 程序。为此,我添加了一个应该编译程序并将其安装到映像中的新配方。

我的问题是我必须包含一些内核头文件,例如`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}
}

当前消息


| 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.

我知道我必须让编译器知道内核头文件,但我无法找到有关如何执行此操作的任何提示。感谢您提前提供的所有帮助!

我认为您需要添加 libusb 作为食谱的依赖项。

将以下行添加到您的食谱中:

DEPENDS = "libusb"