compiler can't find modbus.h

Asked by santiago

Hi all,

Just downloaded libmodbus 1.2.3 and edited the file src/Makefile.am according to revision 18. Then compiled and installed. Then I added a /usr/local/lib/ line to my /etc/ld.so.conf file and ran ldconfig as root.

When I tried to compile the test program using

 gcc test-modbus.c -o test-modbus

the compiler complained with:

test-modbus.c:27:20: error: modbus.h: No such file or directory
test-modbus.c: In function ‘main’:
test-modbus.c:44: error: ‘modbus_param_t’ undeclared (first use in this function)
test-modbus.c:44: error: (Each undeclared identifier is reported only once
test-modbus.c:44: error: for each function it appears in.)
test-modbus.c:44: error: expected ‘;’ before ‘mb_param’
test-modbus.c:50: error: ‘mb_param’ undeclared (first use in this function)
test-modbus.c:51: error: ‘TRUE’ undeclared (first use in this function)

I verified that the modbus.h file exists in /usr/local/include/modbus/ and I know that gcc will look for include files in /usr/local/include.

Am I doing something wrong or have a bad gcc invocation? Any comments or suggestions are appreciated. Thanks!

Santiago

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
Best Stéphane Raimbault (sra) said :
#1

I'm going to release a new version to fix modbus.h installation (1.2.4) (fixed in revno 17)
https://code.launchpad.net/~sra/libmodbus/libmodbus-1.2

This line works fine if I copy modbus.h in /usr/local/include (check file rights)
gcc -I/usr/local/include/modbus `pkg-config glib-2.0 --cflags --libs` -L/usr/local/lib -lmodbus test-modbus.c -o test-modbus

The trunk is easier to compile with `pkg-config modbus --cflags --libs`

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

Thanks Stéphane Raimbault, that solved my question.

Revision history for this message
Akbar (akbar-2667) said :
#3

I have the same problem when I try to compile and run test-modbus
test-modbus.c:44: error: ‘modbus_param_t’ undeclared (first use in this function)
test-modbus.c:44: error: (Each undeclared identifier is reported only once
test-modbus.c:44: error: for each function it appears in.)
test-modbus.c:44: error: expected ‘;’ before ‘mb_param’
test-modbus.c:50: error: ‘mb_param’ undeclared (first use in this function)
test-modbus.c:51: error: ‘TRUE’ undeclared (first use in this function)

what the should I do?

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

Same question, same answer!

Revision history for this message
Akbar (akbar-2667) said :
#5

I mean Iam new to linux , so i don't know where you want me to place the modbus.h, I mean in which folder you want me to place it.

Thanks

Revision history for this message
Akbar (akbar-2667) said :
#6

when Iam installing libmodbus-1.2.0 ,It gives me the error such .
can you give any suggestions to overcome this problem.

test -z "/usr/local/lib" || /bin/mkdir -p "/usr/local/lib"
 /bin/sh ../libtool --mode=install /usr/bin/install -c 'libmodbus.la' '/usr/local/lib/libmodbus.la'
/usr/bin/install -c .libs/libmodbus.so.0.0.0 /usr/local/lib/libmodbus.so.0.0.0
/usr/bin/install: cannot create regular file `/usr/local/lib/libmodbus.so.0.0.0': Permission denied
make[2]: *** [install-libLTLIBRARIES] Error 1
make[2]: Leaving directory `/home/build/libmodbus-1.2.0/libmodbus-1.2.0/src'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/build/libmodbus-1.2.0/libmodbus-1.2.0/src'
make: *** [install-recursive] Error 1

Thanks

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

Akbar,

I can only advise you to read a book about Linux!
Sorry, I don't have time to answer your questions.