首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使gps.h进入Yocto食谱构建?

如何使gps.h进入Yocto食谱构建?
EN

Stack Overflow用户
提问于 2022-02-24 15:26:25
回答 1查看 205关注 0票数 0

我已经建立了一个简单的食谱,只要我不需要gps.h就行了

代码语言:javascript
复制
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

代码语言:javascript
复制
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项目/配方中?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-24 16:10:07

让我抄袭你的食谱,并首先添加一些评论:

代码语言:javascript
复制
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配方的包。

所以,试着:

代码语言:javascript
复制
DEPENDS += "gpsd"

因此,最后的配方如下:

代码语言:javascript
复制
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"

唯一剩下的就是测试。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71254360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档