Help Me With Cross compilation Of Arm-linux -gcc with respect to MODBUS

Asked by Karthik.K.M.

[root@karthik modbus1]# arm-linux-gcc -o modclient modclient3.c -lmodbusmodclient3.c:6:20: error: modbus.h: No such file or directory
modclient3.c: In function 'main':
modclient3.c:14: error: 'modbus_t' undeclared (first use in this function)
modclient3.c:14: error: (Each undeclared identifier is reported only once
modclient3.c:14: error: for each function it appears in.)
modclient3.c:14: error: 'ctx' undeclared (first use in this function)
modclient3.c:15: error: 'uint8_t' undeclared (first use in this function)
modclient3.c:15: error: expected ';' before 'value'
modclient3.c:16: error: 'query' undeclared (first use in this function)
modclient3.c:26: error: 'uint16_t' undeclared (first use in this function)
modclient3.c:26: error: 'tab_rp_registers' undeclared (first use in this function)
modclient3.c:30: error: 'TRUE' undeclared (first use in this function)
modclient3.c:32: error: expected expression before ')' token
modclient3.c:39: warning: format '%s' expects type 'char *', but argument 3 has type 'int'
modclient3.c:82: error: 'EMBXILADD' undeclared (first use in this function)

I tried exporting path for modbus.h:result it didnt work
Then I copied all the header files of modbus.h and others into the directory where the program:it didnt work
then I even copied /libmodbus/src into the directory too:still it didnt work
i even done arm-linux-gcc -l /usr/local/include -o modclient modclient3.c -lmodbus :it didnt work

please help.

P.S:normal compilation gcc -o modclient modclient3.c -lmodbus works fine and even executed the program with success.

Question information

Language:
English Edit question
Status:
Solved
For:
libmodbus Edit question
Assignee:
No assignee Edit question
Solved by:
Karthik.K.M.
Solved:
Last query:
Last reply:
Revision history for this message
Karthik.K.M. (karthikkm1987) said :
#1

Hey I got the answer I even compiled and proted the modbus program into mini2440 and executed it .It works fine.

you should include all the modbus .c files from src directory of libmodbus into the gcc command.
example

[root@karthik modbus1]# arm-linux-gcc -o modclient modclient3.c /home/karthik/project2/libmodbus-3.0.1/src/modbus.c /home/karthik/project2/libmodbus-3.0.1/src/modbus-tcp.c /home/karthik/project2/libmodbus-3.0.1/src/modbus-rtu.c /home/karthik/project2/libmodbus-3.0.1/src/modbus-data.c

or u can do user friendly by making a shell script of that.and dont forget to copy and paste header files into the directory of your program.

Revision history for this message
Karthik.K.M. (karthikkm1987) said :
#2

Hey I got the answer I even compiled and proted the modbus program into mini2440 and executed it .It works fine.

you should include all the modbus .c files from src directory of libmodbus into the gcc command.
example

[root@karthik modbus1]# arm-linux-gcc -o modclient modclient3.c /home/karthik/project2/libmodbus-3.0.1/src/modbus.c /home/karthik/project2/libmodbus-3.0.1/src/modbus-tcp.c /home/karthik/project2/libmodbus-3.0.1/src/modbus-rtu.c /home/karthik/project2/libmodbus-3.0.1/src/modbus-data.c

or u can do user friendly by making a shell script of that.and dont forget to copy and paste header files into the directory of your program.