我已经建立了一个简单的食谱,只要我不需要gps.h就行了
recipes/foo (dunfell) $ cat foo_3.0.0.bb
DESCRIPTION = "FOO Daemon"
LICENSE = "CLOSED"
SRC_URI = " file://*.* \
"
S = "${WORKDIR}"
INSANE_SKIP_${PN} = "ldflags"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
INHIBIT_PACKAGE_STRIP = "1"
do_compile() {
cd ${S}/src
make
cp foo ~/
cd -
}
do_install() {
install -d ${D}${bindir}
install -m 0755 foo ${D}${bindir}
}gps.h在我的本地机器上的/usr/include中,但是由于Yocto正在交叉编译,它提供了一个合理的解释为什么它不能使用本地/usr/include/gps.h。
cc1: error: include location "/usr/include" is unsafe for cross-compilation [-Werror=poison-system-directories]
foo.c:54:10: fatal error: gps.h: No such file or directory
54 | #include <gps.h>
| ^~~~~~~
cc1: all warnings being treated as errors我尝试过IMAGE_INSTALL_append " libgps-dev"和" gps-lib-dev"在我的layer.conf中,但这两种工作都没有。
如何在构建时将gps.h头放到Yocto项目/配方中?
发布于 2022-02-24 16:10:07
让我抄袭你的食谱,并首先添加一些评论:
DESCRIPTION = "FOO Daemon"
LICENSE = "CLOSED"
# --- COMMENT ---
# It is not recommended to use "*" with SRC_URI,
# as Yocto will not keep track of your files if you edit them
# so it will never rebuild automaticall after a change
# Best practice is to sepecify the local files like:
# SRC_URI = "file://src"
# This will make bitbake unpacks the "src" folder into ${WORKDIR}
# --- COMMENT ---
SRC_URI = " file://*.* \
"
# --- COMMENT ---
# The ${S} variable is the defautl workind directory for compilation tasks,
# do_configure, do_compile, ...,
# So, if you have "src" folder that will be unpacked into ${WORKDIR}
# you need to set S to that:
# S = "${WORKDIR}/src"
# --- COMMENT ---
S = "${WORKDIR}"
INSANE_SKIP_${PN} = "ldflags"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
INHIBIT_PACKAGE_STRIP = "1"
# --- COMMENT ---
# If your project has a "Makefile" you can use the "autotools" class
# it runs oe_runmake automatically
# inherit autotools
# If you want to copy the output to your home directory you can do it in "do_install"
# If you use autotools you do not need do_compile
# --- COMMENT ---
do_compile() {
cd ${S}/src
make
cp foo ~/
cd -
}
do_install() {
install -d ${D}${bindir}
install -m 0755 foo ${D}${bindir}
}
# --- COMMENT ---
# Do not forget to specify your output files into FILES for do_package to work well
# FILES_${PN} = "${bindir}/foo"
# --- COMMENT ---现在,在处理这个问题之后,如果您的菜谱在构建时需要一些东西,而不是在同一菜谱的工作目录中需要依赖,因为如果要将libgps添加到IMAGE_INSTALL中,它将出现在rootfs中,而不是在构建时。
因此,要做到这一点,您需要使用DEPENDS指定依赖关系配方。
我一直在寻找gps.h,我找到了带有gpsd配方的包。
所以,试着:
DEPENDS += "gpsd"因此,最后的配方如下:
DESCRIPTION = "FOO Daemon"
LICENSE = "CLOSED"
SRC_URI = "file://src"
S = "${WORKDIR}/src"
DEPENDS += "gpsd"
inherit autotools
do_install(){
install -d ${D}${bindir}
install -m 0755 foo ${D}${bindir}
cp foo ~/
}
FILES_${PN} = "${bindir}/foo"唯一剩下的就是测试。
https://stackoverflow.com/questions/71254360
复制相似问题