Install the libmodbus library and compile programs with - Raspberry Pi Forums


hi all,

have problems modbus communications ardushield raspberry. testing "cookinghacks" library , wasn't stable , fails or give me errors transmissions, decided change libmodbus library github.

have downloaded it, extracted correctly , afterwards:

code: select all

 ./configure && make install 
(first generate configure script if required)

code: select all

 ./autogen.sh 
here solved problems of installing executing process root permissions.

after done (maybe not done), tried compile 1 of examples in /test directory inside ;

code: select all

gcc random-test-server.c -o random-test-server 'pkg-config --libs --cflags libmodbus' 
here when errors appear: :(
random-test-client.c:15:20: fatal error: modbus.h: no such file or directory
if file "modbus.h" in same directory.
errors this;
gcc: error: pkg-config: no such file or directory
gcc: error: libmodbus: no such file or directory
gcc: error: unrecognized command line option ‘--libs’
gcc: error: unrecognized command line option ‘--cflags’
have tried move lot of files between directories , impossible compilation done library.

need guidelines install , compilation please! :?

will help? it's makefile project using libmodbus installed per instructions

code: select all

# # solid makefile # cc = gcc cflags = -c -wall  ldflags = -rdynamic -lrt -lm -ldl -lpthread inc = -i/usr/include/modbus   # list of sources: sources = ab_client.c objects = $(sources:.c=.o)   # name of executable target: executable = ab_client   cflags += `pkg-config --cflags libmodbus` cflags += `pkg-config --cflags gtk+-3.0` ldflags += `pkg-config --libs libmodbus` ldflags += `pkg-config --libs gtk+-3.0`   all:	$(sources) $(executable)  $(executable): $(objects) 	$(cc) $(objects) -o $@ $(ldflags)   .c.o: 	$(cc) $(inc) $(cflags) $< -o $@   clean: 	rm $(objects) $(executable)


raspberrypi



Comments