Closed AWV7600 closed 6 years ago
Please change Makefile according to libmodbus installation.
orangepi@orangepipc:~$ wget -c https://libmodbus.org/releases/libmodbus-3.1.4.tar.gz
orangepi@orangepipc:~$ tar zxvf libmodbus-3.1.4.tar.gz
orangepi@orangepipc:~$ cd libmodbus-3.1.4
orangepi@orangepipc:~/libmodbus-3.1.4$ ./configure
orangepi@orangepipc:~/libmodbus-3.1.4$ make
orangepi@orangepipc:~/libmodbus-3.1.4$ sudo make install
orangepi@orangepipc:~$ git clone https://github.com/gianfrdp/SDM120C.git
orangepi@orangepipc:~$ cd SDM120C/
orangepi@orangepipc:~/SDM120C$ sed -i -s 's|pkg-config --cflags libmodbus|-I/usr/local/include/modbus|g' Makefile
orangepi@orangepipc:~/SDM120C$ sed -i -s 's|pkg-config --libs libmodbus|-L/usr/local/lib -lmodbus|g' Makefile
orangepi@orangepipc:~/SDM120C$ sed -i -s 's|`||g' Makefile
orangepi@orangepipc:~/SDM120C$ cat Makefile CC = gcc CFLAGS = -O2 -Wall -g -I/usr/local/include/modbus LDFLAGS = -O2 -Wall -g -L/usr/local/lib -lmodbus
SDM = sdm120c %.o: %.c $(CC) -c -o $@ $< $(CFLAGS)
${SDM}: sdm120c.o $(CC) -o $@ sdm120c.o $(LDFLAGS) chmod 4711 ${SDM}
strip: strip ${SDM}
clean: rm -f *.o ${SDM}
install: ${SDM} install -m 4711 $(SDM) /usr/local/bin
uninstall: rm -f /usr/local/bin/$(SDM)
orangepi@orangepipc:~/SDM120C$ make
gcc -c -o sdm120c.o sdm120c.c -O2 -Wall -g -I/usr/local/include/modbus
gcc -o sdm120c sdm120c.o -O2 -Wall -g -L/usr/local/lib -lmodbus
chmod 4711 sdm120c
orangepi@orangepipc:~/SDM120C$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ ./sdm120c
sdm120c 1.3.5.3: ModBus RTU client to read EASTRON SDM120C smart mini power meter registers
orangepi@orangepipc:~/SDM120C$ cat /etc/ld.so.conf.d/libc.conf
/usr/local/lib
orangepi@orangepipc:~/SDM120C$ sudo ldconfig
orangepi@orangepipc:~/SDM120C$ sudo ldconfig -p | grep local
libmodbus.so.5 (libc6,hard-float) => /usr/local/lib/libmodbus.so.5
libmodbus.so (libc6,hard-float) => /usr/local/lib/libmodbus.so
orangepi@orangepipc:~/SDM120C$ ./sdm120c
sdm120c 1.3.5.3: ModBus RTU client to read EASTRON SDM120C smart mini power meter registers
Hello,
I 've got trouble while installing SDM on my Odroid (ARMv7). Installation of libmodbus 3.1.4 seems ok but SDM gives some errors. See the history below... What do you think about it ? Thanks by advance for your answer.
root@odroid:/home/libmodbus/libmodbus-3.1.4# make install Making install in src /bin/mkdir -p '/usr/local/lib' /bin/bash ../libtool --mode=install /usr/bin/install -c libmodbus.la '/usr/local/lib' libtool: install: /usr/bin/install -c .libs/libmodbus.so.5.1.0 /usr/local/lib/libmodbus.so.5.1.0 libtool: install: (cd /usr/local/lib && { ln -s -f libmodbus.so.5.1.0 libmodbus.so.5 || { rm -f libmodbus.so.5 && ln -s libmodbus.so.5.1.0 libmodbus.so.5; }; }) libtool: install: (cd /usr/local/lib && { ln -s -f libmodbus.so.5.1.0 libmodbus.so || { rm -f libmodbus.so && ln -s libmodbus.so.5.1.0 libm odbus.so; }; }) libtool: install: /usr/bin/install -c .libs/libmodbus.lai /usr/local/lib/libmodbus.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/sbin" ldconfig -n /usr/loc al/lib
Libraries have been installed in: /usr/local/lib
If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the '-LLIBDIR' flag during linking and do at least one of the following:
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
/bin/mkdir -p '/usr/local/include/modbus' /usr/bin/install -c -m 644 modbus.h modbus-version.h modbus-rtu.h modbus-tcp.h '/usr/local/include/modbus' Making install in doc make[2]: Nothing to be done for
install-exec-am'. Making install in tests make[2]: Nothing to be done for
install-exec-am'. make[2]: Nothing to be done forinstall-data-am'. make[2]: Nothing to be done for
install-exec-am'. /bin/mkdir -p '/usr/local/share/doc/libmodbus' /usr/bin/install -c -m 644 MIGRATION README.md '/usr/local/share/doc/libmodbus' /bin/mkdir -p '/usr/local/lib/pkgconfig' /usr/bin/install -c -m 644 libmodbus.pc '/usr/local/lib/pkgconfig' root@odroid:/home/libmodbus/libmodbus-3.1.4# cd .. root@odroid:/home/libmodbus# cd ../SDM root@odroid:/home/SDM# export LD_RUNPATH=/usr/local/lib root@odroid:/home/SDM# make clean rm -f .o sdm120c root@odroid:/home/SDM# make gcc -c -o sdm120c.o sdm120c.c -O2 -Wall -gpkg-config --cflags libmodbus
gcc -c -o RS485_lock.o RS485_lock.c -O2 -Wall -gpkg-config --cflags libmodbus
gcc -c -o log.o log.c -O2 -Wall -gpkg-config --cflags libmodbus
log.c: In function ‘log_message’: log.c:59:8: warning: format not a string literal and no format arguments [-Wformat-security] fprintf(stderr, buffer); ^ log.c:68:13: warning: format not a string literal and no format arguments [-Wformat-security] syslog(LOG_INFO, versionbuffer); ^ log.c:71:13: warning: format not a string literal and no format arguments [-Wformat-security] syslog(LOG_INFO, parent); ^ log.c:72:13: warning: format not a string literal and no format arguments [-Wformat-security] syslog(LOG_INFO, cmdline); ^ log.c:75:9: warning: format not a string literal and no format arguments [-Wformat-security] syslog(LOG_INFO, buffer); ^ gcc -O2 -Wall -gpkg-config --libs libmodbus
-o sdm120c sdm120c.o RS485_lock.o log.o sdm120c.o: In functionexit_error': /home/SDM/sdm120c.c:228: undefined reference to
modbus_close' /home/SDM/sdm120c.c:229: undefined reference tomodbus_free' sdm120c.o: In function
getMeasureFloat': /home/SDM/sdm120c.c:358: undefined reference tomodbus_read_input_registers' /home/SDM/sdm120c.c:364: undefined reference to
modbus_strerror' /home/SDM/sdm120c.c:363: undefined reference tomodbus_strerror' /home/SDM/sdm120c.c:364: undefined reference to
modbus_strerror' sdm120c.o: In functionreadRegisters': /home/SDM/sdm120c.c:452: undefined reference to
modbus_read_input_registers' /home/SDM/sdm120c.c:458: undefined reference tomodbus_strerror' /home/SDM/sdm120c.c:457: undefined reference to
modbus_strerror' /home/SDM/sdm120c.c:458: undefined reference tomodbus_strerror' sdm120c.o: In function
getConfigBCD': /home/SDM/sdm120c.c:509: undefined reference tomodbus_read_registers' /home/SDM/sdm120c.c:512: undefined reference to
modbus_strerror' sdm120c.o: In functionchangeConfigHex': /home/SDM/sdm120c.c:552: undefined reference to
modbus_write_registers' /home/SDM/sdm120c.c:557: undefined reference tomodbus_strerror' sdm120c.o: In function
changeConfigFloat': /home/SDM/sdm120c.c:568: undefined reference tomodbus_set_float' /home/SDM/sdm120c.c:580: undefined reference to
modbus_write_registers' /home/SDM/sdm120c.c:585: undefined reference tomodbus_strerror' sdm120c.o: In function
changeConfigBCD': /home/SDM/sdm120c.c:603: undefined reference tomodbus_write_registers' /home/SDM/sdm120c.c:608: undefined reference to
modbus_strerror' sdm120c.o: In functionmain': /home/SDM/sdm120c.c:1044: undefined reference to
modbus_new_rtu' /home/SDM/sdm120c.c:1065: undefined reference tomodbus_set_byte_timeout' /home/SDM/sdm120c.c:1068: undefined reference to
modbus_set_response_timeout' /home/SDM/sdm120c.c:1096: undefined reference tomodbus_set_error_recovery' /home/SDM/sdm120c.c:1102: undefined reference to
modbus_connect' /home/SDM/sdm120c.c:1118: undefined reference tomodbus_set_slave' /home/SDM/sdm120c.c:1460: undefined reference to
modbus_close' /home/SDM/sdm120c.c:1461: undefined reference tomodbus_free' /home/SDM/sdm120c.c:1062: undefined reference to
modbus_set_byte_timeout' /home/SDM/sdm120c.c:1227: undefined reference tomodbus_close' /home/SDM/sdm120c.c:1228: undefined reference to
modbus_free' /home/SDM/sdm120c.c:1210: undefined reference tomodbus_close' /home/SDM/sdm120c.c:1211: undefined reference to
modbus_free' /home/SDM/sdm120c.c:1099: undefined reference tomodbus_set_debug' /home/SDM/sdm120c.c:1220: undefined reference to
modbus_close' /home/SDM/sdm120c.c:1221: undefined reference tomodbus_free' /home/SDM/sdm120c.c:1103: undefined reference to
modbusstrerror' collect2: error: ld returned 1 exit status make: ** [sdm120c] Error 1 root@odroid:/home/SDM# sdm120c -a2 -b9600 -z3 -2 -qpievfg /dev/ttyUSB1 NOK