Recipe for c program that use libmodbus

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Recipe for c program that use libmodbus

1,095 次查看
marcoozmg
Contributor I

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

0 项奖励
回复
1 回复

1,077 次查看
Bio_TICFSL
NXP TechSupport
NXP TechSupport
0 项奖励
回复