Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
MinGW make error "undefined reference" in modbus-tcp.c #163
when compiling the newest libmodbus master branch
the libmodbus-5.dll is not created and make breaks with:
the "undefined reference" errors for "getaddrinfo" and "freeaddrinfo"
i suggest in src/modbus-tcp.c to replace lines 32-35 with
if you prefer i can also send a pull request ?
yes, _ WIN32_WINNT_WINXP = 0x0501 .
first i've tried it with #ifndef , but it did not work: make gave the same compile error.
but in the MinGW header ws2tcpip.h in line 386 is the condition
checked before getaddrinfo and freeaddrinfo are managed in ws2tcpip.h .
according to the infos from the microsoft developer network
with WINVER and _ WIN32_WINNT a developer can set the minimum required
to take this into account i suggest the tested solution:
when WINVER and _ WIN32_WINNT are not set by a developer
I use libmodbus 3.1.1 on Windows 7 64bit with Qt 5.2 (mingw48 edition).
To successfully link I have added the following to the .pro file:
Now the libraries "libws2_32.a" and "libwsock32.a" in the mingw folder "D:\Qt\Qt5.2.0\Tools\mingw48_32\i686-w64-mingw32\lib" are used.
This fixed the issue for me.
many thanks for your solution !
following your idea, i've successfully tested another alternative,
in configure.ac adding
somewhere between AC_INIT and AC_OUTPUT, for example after
in the empty line 71