I’m working on a Yocto project and need to create and link a shared library to one of the packages. The directory structure of the shared library source code is as follows:
library
├── svc
│ ├── src
│ │ └── library_common.c
│ ├── inc
│ │ └── library_common.h
├── Makefile.am
├── configure.ac
└── library.pc.in
I’ve written Makefile.am
and configure.ac
as shown below:
Makefile.am:
ACLOCAL_AMFLAGS = -I m4
AM_CFLAGS = -Wundef
-Wstrict-prototypes
-fno-short-enums
-fpic
-Wall
-Wunused
AM_CPPFLAGS = -I$(srcdir)/svc/inc
AM_LDFLAGS = $(TARGET_LDFLAGS)
-g
-fexceptions
-fpie
lib_LTLIBRARIES = liblibrary.la
source_dir = svc/src
header_dir = svc/inc
source_files = $(source_dir)/library_common.c
header_files = $(header_dir)/library_common.h
required_libs = -lpthread -lrt
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = library.pc
EXTRA_DIST = $(pkgconfig_DATA)
liblibrary_la_SOURCES = $(source_files) $(header_files)
liblibrary_la_CFLAGS = $(AM_CFLAGS)
liblibrary_la_CPPFLAGS = $(AM_CPPFLAGS)
liblibrary_la_LDFLAGS = $(AM_LDFLAGS) -shared -version-info 1:0:0
liblibrary_la_LIBADD = $(required_libs)
configure.ac:
AC_PREREQ(2.61)
AC_INIT([library], 1.0.0)
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR([svc/src/library_common.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AC_PROG_LIBTOOL
PKG_PROG_PKG_CONFIG
LT_INIT()
AC_CONFIG_FILES([Makefile
library.pc])
AC_OUTPUT
library_git.bb:
inherit pkgconfig autotools-brokensep qprebuilt deploy
DESCRIPTION = "library"
HOMEPAGE = "http://support.cdmatech.com"
LICENSE = "****"
LIC_FILES_CHKSUM = "****"
SRC_DIR = "${WORKSPACE}/data/library"
FILESPATH =+ "${WORKSPACE}/data:"
SRC_URI = "file://library/"
S = "${WORKDIR}/library"
# Package Revision (update whenever recipe is changed)
PR = "r1"
I’ve added the library to the DEPENDS
variable in the package BitBake recipe and included $(LIBRARY_CFLAGS)
in the bin_CPPFLAGS
variable and $(MBOEM_LIBS)
in the bin_LDADD
variable.
However, when I run bitbake package
, I encounter the following error:
| in_some_file:75:10: fatal error: library_common.h: No such file or directory
| 75 | #include "library_common.h"
I’ve tried various solutions but haven’t been able to resolve this issue. Could anyone help me out? Apologies for the lengthy question.
4