stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.33k stars 1.71k forks source link

compile error: "undefined reference to _imp__modbus_" #115

Closed ghost closed 11 years ago

ghost commented 11 years ago

when compiling the actual libmodbus master branch with GCC 4.7.2 in MinGW on Win7 via the steps:

autogen.sh
./configure
make

the "libmodbus-5.dll" is not created and make breaks with:

CC     modbus.lo
modbus.c:1662:6: warning: 'modbus_free' redeclared without dllimport attribute:
                          previous dllimport ignored [-Wattributes]
CC     modbus-data.lo
modbus-data.c:69:6: warning: 'modbus_set_bits_from_bytes' redeclared without dllimport attribute:
                             previous dllimport ignored [-Wattributes]
CCLD   libmodbus.la
.libs/modbus.o: In function `modbus_reply':
src/modbus.c:853: undefined reference to `_imp__modbus_set_bits_from_bytes'
.libs/modbus-rtu.o: In function `modbus_new_rtu':
src/modbus-rtu.c:1161: undefined reference to `_imp__modbus_free'
.libs/modbus-tcp.o: In function `modbus_new_tcp':
src/modbus-tcp.c:796: undefined reference to `_imp__modbus_free'
.libs/modbus-tcp.o: In function `modbus_new_tcp_pi':
src/modbus-tcp.c:837: undefined reference to `_imp__modbus_free'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [libmodbus.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
stephane commented 11 years ago

Fixed by testing against _MSC_VER. Thanks for the report. https://github.com/stephane/libmodbus/commit/4d76d215c6cdfc77a4c8caba05639b75124e9cb8