embeddedyoctobitbakesocketcan

Bitbake LibSocketCAN


I am trying to build libsocketcan into my image. To add libsocketcan In my main application recipe I added IMAGE_INSTALL_append += " libsocketcan ". When debugging my application with Eclipse this works perfectly. When I attempt to bitbake my application I am told

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

I am not sure where I am missing my dependency. 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

I believe this is the only file that would make a difference. Has anyone else ever faced this? What else do I need to do to allow my bitbake to find the include?

Edit: recipe as requestes

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"

Edit 2: main application recipe

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
}

Solution

  • libsocketcan provides these packages:

    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
    

    Adding DEPENDS += "libsocketcan" will cause all those files to be populated into your custom layer's working directory.

    NOTE Your recipe seems to do not install your MAIN_Application output binary file. So your recipe should look like:

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

    Just make sure that MAIN_Application is the right binary name.