How can i use libmodbus in Embedded Linux

I’m working on the libmodbus library. I can communicate between the virtual and host computer using the libmodbus interface. But when I try to compile the same code and libraries for the colibri device, I get the “modbus library not found” error. How can I run the libmodbus library for embedded linux? What should I do, how to add the modbus library for cross-compilation to embedded linux.

Without knowing much of anything about this libmodbus I guess you would need to build a custom BSP image with libmodbus integrated by adding it to IMAGE_INSTALL in conf/local.conf (e.g. IMAGE_INSTALL_append = " libmodbus").

First of all, thanks for the response. But I wonder if it’s not possible to use this library without what you’re talking about?

You are, of course, very welcome to find any other way.

Have you made any progress on incorporating libmodbus into Embedded Linux?

I am trying to use the same library on Apalix iMX6, but I can’t figure out how to compile on device or cross-compile. I am open to other Modbus libraries, but have not found any yet.

Hi @aronreman17

Have you tried out the solution proposed below by @marcel.tx.

Best regards,

Well, first I was interested if the solution proposed by @marcel.tx was actually tested successfully before I committed to making changes to the BSP. So, no I have not tried this solution yet, but I am also interested to see if anyone was able to incorporate the library without modifying the BSP.

We haven’t tested this. You are free to try it out.

Best regards,