What is the correct way to bundle custom libraries into a system image?

What would be the steps to add libraries to /usr/lib that my apps could then later use? I guess I would need to add them to the yocto system image, but I am having a hard time figuring out where to add them. I got them cross-compiled already so I have some .so files, I just need to add them to the image. How would I go about doing this?

I want to be able to include a few libraries but I don’t want them to affect our code size to avoid having large update sizes in the future.

1 Like

Hello Frederic,

These recipes show examples on how to add *.so files to the image:

meta-swi /common/recipes-support/device-mapper/device-mapper_1.02.28.bb

${bindir} is usually equal to /usr/bin

Another example showing how to compile and install a helloworld to /usr/bin:

# This file was derived from the 'Hello World!' example recipe in the
# Yocto Project Development Manual.

DESCRIPTION = "Simple helloworld application"
SECTION = "examples"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PR = "r1"


SRC_URI = "file://helloworld.c"

S = "${WORKDIR}"

do_compile() {
	${CC} helloworld.c -o helloworld

do_install() {
	install -d ${D}${bindir}
	install -m 0755 helloworld ${D}${bindir}


1 Like

Yes,you can add in yocto system image.If you have already having .so file which is compiled.
Also you can create softlink
Steps to add libraries in yocto:
SUMMARY = “lib sample”
SECTION = “libs”

SRC_URI = “file://lib.so” <.so file should be present in the path of the recipes>

INSANE_SKIP_${PN} = “ldflags”
SOLIBS = “.so”

do_install () {
install -d ${D}${libdir}
install -m 0755 ${WORKDIR}/lib.so ${D}${libdir}

1 Like