compilation problem

Asked by santiago

I just downloaded the latest 64 bit ubuntu package, installed it on a debian machine, and tried to compile random-test-master.c

Using this gcc invocation:

gcc -I/usr/include/modbus `pkg-config glib-2.0 --cflags --libs` -L/usr/local/lib -lmodbus random-test-master.c -o rtest

I get the following error:

random-test-master.c: In function ‘main’:
random-test-master.c:57: error: ‘modbus_param_t’ undeclared (first use in this function)
random-test-master.c:57: error: (Each undeclared identifier is reported only once
random-test-master.c:57: error: for each function it appears in.)
random-test-master.c:57: error: expected ‘;’ before ‘mb_param’
random-test-master.c:63: error: ‘mb_param’ undeclared (first use in this function)

Any idea of what's going on? if I use this other gcc invocation (suggested in the README, except that I changed "modbus" to "libmodbus", otherwise pkg-config complains!)

gcc random-test-master.c -o random-test-master `pkg-config --libs --cflags libmodbus`

I get the same error again.

Help is much appreciated, thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
libmodbus Edit question
Assignee:
No assignee Edit question
Solved by:
Stéphane Raimbault
Solved:
Last query:
Last reply:
Revision history for this message
santiago (repepo) said :
#1

Update:

I realized that the test programs are written for the stable release, not for the latest release... it is a different API so no wonder they won't compile. Are there any examples written using the new API?

Revision history for this message
Best Stéphane Raimbault (sra) said :
#2

How have you got the test programs?

If you install libmodbus v2.9.3 + dev packages, you will have this directory:

/usr/share/doc/libmodbus-dev/examples

Take time to read the README file which mentions how to compile easily:

gcc random-test-server.c -o random-test-server `pkg-config --libs --cflags libmo
dbus`

Revision history for this message
santiago (repepo) said :
#3

Thanks Stéphane Raimbault, that solved my question.