So, I am experimenting with a Raspberry Pi computer, fairly inexperienced in linux but lots of windows and programming experience. I'm following these instructions to get my computer talking MODBUS over ethernet.
Basically I ran "sudo apt-get install libmodbus5 libmodbus-dev" which seemed to execute okay (to my novice eye) lots of feedback but no errors or warnings.
Then I wrote some sample code which has #include "modbus.h" and calls functions which (according to the documentation) should be in modbus_new_tcp(), etc. Then I ran the recommended compiling command:
$gcc bandwidth-server-one.c -o bandwidth-server-one `pkg-config –libs –cflags libmodbus`
but first it had trouble finding the modbus.h file. So I found the file in /usr/include and I included (after google searching) the parameter to my command:
$gcc bandwidth-server-one.c -o bandwidth-server-one `pkg-config –libs –cflags libmodbus` -I/usr/include/modbus
and it found the include file but reported a bunch of "undefined reference" errors for my modbus calls such as modbus_new_tcp.
Then I found the library (I think) in /user/lib, specifically these files:
So I added the -L option as follows:
$gcc bandwidth-server-one.c -o bandwidth-server-one `pkg-config –libs –cflags libmodbus` -I/usr/include/modbus -L/usr/lib
and I still got the undefined reference errors.
So it appears that the "apt-get" command didn't do EVERYTHING I needed to do to start using this library, or I am executing the compiler incorrectly.
Can any of you linux experts please give me some pointers?
I really appreciate any thoughts.