Bitbake LibSocketCAN

Bitbake LibSocketCAN

我正在尝试将 libsocketcan 构建到我的图像中。要添加 libsocketcan 在我的主要应用程序配方中,我添加了 IMAGE_INSTALL_append += " libsocketcan "。当使用 Eclipse 调试我的应用程序时,这非常有效。当我尝试对我的应用程序进行 bitbake 时,我被告知

fatal error: libsocketcan.h: No such file or directory

我不确定我在哪里遗漏了我的依赖项。 Makefile.am

AUTOMAKE_OPTIONS = foreign subdir-objects

bin_PROGRAMS = MAIN_Application

MAIN_Application_LDADD = -lsocketcan -lpthread

AM_CPPFLAGS = \
-I$(srcdir)/include \
-I$(srcdir)/include/utilities \
-I$(srcdir)/include/comms

MAIN_Application_SOURCES = \
src/main.c \
src/scheduler.c \
src/utilities/time_conversions.c \
src/utilities/ring_buffer.c \
src/utilities/logger.c \
src/comms/can.c

我相信这是唯一会有所作为的文件。还有其他人遇到过这个吗?我还需要做什么才能让我的 bitbake 找到 include?

编辑:根据要求编辑食谱

LICENSE = "MIT"
IMAGE_LINGUAS = " "

# Base image Install
IMAGE_INSTALL = " packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"

# Configure image base size
IMAGE_ROOTFS_SIZE ?= "4096"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 2048", "", d)}"

# User preferences 
inherit core-image
inherit extrausers

# Change root password (note the capital -P)
EXTRA_USERS_PARAMS = "\
  usermod -P toor  root; \
  useradd -P michael -G sudo  michael; \
  "

# uncomment the line %sudo ALL=(ALL) ALL in /etc/sudoers
modify_sudoers() {
    sed 's/# %sudo/%sudo/' < ${IMAGE_ROOTFS}${sysconfdir}/sudoers > ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp
    mv ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp ${IMAGE_ROOTFS}${sysconfdir}/sudoers
}
ROOTFS_POSTPROCESS_COMMAND_append = " modify_sudoers;"

# Dependencies
DEPENDS = " libsocketcan "

# Install necessary libraries
IMAGE_INSTALL_append += " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append += " can-utils "
IMAGE_INSTALL_append += " libsocketcan"
IMAGE_INSTALL_append += " sudo "
IMAGE_INSTALL_append += " iw wireless-tools wpa-supplicant "

# Install SMG applications
IMAGE_INSTALL_append += " udevrules "
IMAGE_INSTALL_append += " mainapplication "

# Apply kernel customizations
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://kernel_customization.cfg"

# Remove image features
IMAGE_INSTALL_remove += " packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS = " udev-hwdb" 

#MKUBIFS_ARGS="--leb-size 126976 --min-io-size 2048 --max-leb-cnt 3600"
#UBINIZE_ARGS="--peb-size 128KiB --min-io-size 2048 --sub-page-size 2048"
#IMAGE_FSTYPES += " ubi ubifs"

编辑 2:主要应用配方

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "\
    file://MAIN_Application \
        file://services \   
    "

inherit autotools systemd

S = "${WORKDIR}/MAIN_Application"

SYSTEMD_SERVICE_${PN} = "MAINapplication.service"

do_install_append () {
    install -d ${D}${systemd_system_unitdir}
    install -m 0644 ${WORKDIR}/services/MAINapplication.service ${D}${systemd_system_unitdir}
    sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_system_unitdir}/MAINapplication.service
}

IMAGE_INSTALL_append 将包添加到映像。

这与您的应用程序的 build-time 依赖关系不大。

你要加给你的app.bb是:

取决于 =“libsocketcan”

这个答案只是为了帮助您解决与图像配方相关的一些问题:

这里有一些重要的评论:

  • IMAGE_INSTALL
IMAGE_INSTALL = " packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
...
inherit core-image

永远也永远不要覆盖 core-image 之前的 IMAGE_INSTALL,因为 core-imageIMAGE_INSTALL 不会生效。

  • 变量赋值
IMAGE_INSTALL_append += " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append += " can-utils "
IMAGE_INSTALL_append += " libsocketcan"
IMAGE_INSTALL_append += " sudo "
IMAGE_INSTALL_append += " iw wireless-tools wpa-supplicant "

不要将 append+= 一起使用,仅使用其中之一。

  • 取决于 ?? Image recipes 专门用于收集 recipes 和创建图像 rootfs 和最终图像类型(wic,...) 你不需要 DEPENDS.

  • SRC_URI ?? 这也是一个non-image配方变量,它竟然生效了吗? 将内核配置片段移动到您的自定义 virtual/kernel 包配方。

我推荐你的图片配方如下:

LICENSE = "MIT"
IMAGE_LINGUAS = " "

# Configure image base size
IMAGE_ROOTFS_SIZE ?= "4096"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 2048", "", d)}"

# User preferences 
inherit core-image extrausers

# Change root password (note the capital -P)
EXTRA_USERS_PARAMS = "\
  usermod -P toor  root; \
  useradd -P michael -G sudo  michael; \
  "

# uncomment the line %sudo ALL=(ALL) ALL in /etc/sudoers
modify_sudoers() {
    sed 's/# %sudo/%sudo/' < ${IMAGE_ROOTFS}${sysconfdir}/sudoers > ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp
    mv ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp ${IMAGE_ROOTFS}${sysconfdir}/sudoers
}
ROOTFS_POSTPROCESS_COMMAND_append = " modify_sudoers;"

# Install necessary libraries
IMAGE_INSTALL_append = " packagegroup-core-ssh-openssh \
            can-utils \
            libsocketcan \
            sudo \
            iw wireless-tools wpa-supplicant"

# Install SMG applications
IMAGE_INSTALL_append = " udevrules \
            mainapplication"

# Remove image features
IMAGE_INSTALL_remove += " packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS = " udev-hwdb" 

#MKUBIFS_ARGS="--leb-size 126976 --min-io-size 2048 --max-leb-cnt 3600"
#UBINIZE_ARGS="--peb-size 128KiB --min-io-size 2048 --sub-page-size 2048"
#IMAGE_FSTYPES += " ubi ubifs"

libsocketcan 提供这些包:

tmp/work/aarch64-poky-linux/libsocketcan/0.0.11-r0/image
└── usr
    ├── include
    │   ├── can_netlink.h
    │   └── libsocketcan.h
    ├── lib
    │   ├── libsocketcan.so -> libsocketcan.so.2.3.0
    │   ├── libsocketcan.so.2 -> libsocketcan.so.2.3.0
    │   ├── libsocketcan.so.2.3.0
    │   └── pkgconfig
    │       └── libsocketcan.pc

添加 DEPENDS += "libsocketcan" 将导致所有这些文件填充到自定义图层的工作目录中。

注意 您的食谱似乎没有安装您的 MAIN_Application 输出二进制文件。所以你的食谱应该是这样的:

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "\
    file://MAIN_Application \
        file://services \   
    "

inherit autotools systemd

S = "${WORKDIR}/MAIN_Application"

DEPENDS += "libsocketcan"

SYSTEMD_SERVICE_${PN} = "MAINapplication.service"

do_install_append () {
    install -d ${D}${systemd_system_unitdir}
    install -m 0644 ${WORKDIR}/services/MAINapplication.service ${D}${systemd_system_unitdir}
    sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_system_unitdir}/MAINapplication.service
    install -m 0644 ${S}/MAIN_Application ${D}${bindir}
}

只需确保 MAIN_Application 是正确的二进制名称。