I'm trying to create a Linux image with Yocto project. I need the modbus library for C.
I added the libmodbus in IMAGE_INSTALL_append in the bitbake file of the image. Libmodbus is included in the meta-openembedded that I have.
Now I have a recipe to compile a simple c program (for test purpose) that uses the modbus library (#include <modbus.h>). This program works in my host.
The bitbake file to install the C program is the following:
SUMMARY = "modbustest Recipe"
LICENSE = "CLOSED"
SRC_URI = "file://test.c "
DEPENDS += "libmodbus"
S = "${WORKDIR}"
FILES_${PN} += "${libdir}/*.so"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} test.c -o test -I/${D}/usr/lib/modbus/ -lmodbus
}
do_install_append() {
install -d ${D}/opt/modbustest/bin
install -m 0777 ${WORKDIR}/test ${D}/opt/modbustest/bin
}
FILES_${PN} += "/opt/modbustest/bin"
FILES_SOLIBSDEV = ""
INSANE_SKIP_${PN} += "dev-so"
When I try to create the image, this is the error:
ERROR: modbustest-0.1-r0 do_compile: Execution of '/home/uip/yocto-mx8/build-modbus/tmp/work/aarch64-ts-linux/modbustest/0.1-r0/temp/run.do_compile.3835' failed with exit code 1:
test.c:2:10: fatal error: modbus.h: No such file or directory
2 | #include <modbus.h>
| ^~~~~~~~~~
compilation terminated.
WARNING: exit code 1 from a shell command.I know that library is to link to the do_compile but I don't know how to do.
Probably in the recipe file there are many errors. I copy and paste many solutions from internet but nothing works.
Does someone know how to solve it?
Thank you,
Marco