Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Compile Error of GuruxDLMSClientExample

Compile error of GuruxDLMSClientExample

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By gigoc1 , 31 January, 2022
Forums
General discussion

Dear Sir.
Thank you for your great projects for DLMS c++ library. I want to read the data of the wattmeter operated by dlms protocol. So I built the development to make the "libgurux_dlms_cpp.a"
During compiling steps, I revised the original source in some places like these.
1) Ignoring the IP6 setup
2) switching the function "fopen_s /fopen", "sscanf_s / sscanf" because of not-finding function error
3) adding "#define ERROR_INVALID_FUNCTION 1, #define ERROR_IO_PENDING 976" in communication.h

I tried to make the build the "GuruxDLMSClientExample.cpp" but the compile error was shown as belows.
My pc condition is "Windows 10, MinGW(32 bit)". Pleas help me and thank you for your kindness.

---------------------------------------------------------------------------
obj/GuruxDLMSClientExample.o:GuruxDLMSClientExample.cpp:(.text+0x226): undefined reference to `WSAStartup@8'
obj/GuruxDLMSClientExample.o:GuruxDLMSClientExample.cpp:(.text+0x1563): undefined reference to `WSACleanup@0'
obj/communication.o:communication.cpp:(.text+0x61e): undefined reference to `closesocket@4'
obj/communication.o:communication.cpp:(.text+0x6ed): undefined reference to `socket@12'
obj/communication.o:communication.cpp:(.text+0x708): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0x72e): undefined reference to `htons@4'
obj/communication.o:communication.cpp:(.text+0x746): undefined reference to `inet_addr@4'
obj/communication.o:communication.cpp:(.text+0x770): undefined reference to `gethostbyname@4'
obj/communication.o:communication.cpp:(.text+0x781): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0x7d1): undefined reference to `htons@4'
obj/communication.o:communication.cpp:(.text+0x7e9): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0x843): undefined reference to `setsockopt@20'
obj/communication.o:communication.cpp:(.text+0x864): undefined reference to `connect@12'
obj/communication.o:communication.cpp:(.text+0x875): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0xa62): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0xaf3): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0xb73): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0x104e): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0x2105): more undefined references to `WSAGetLastError@0' follow
obj/communication.o:communication.cpp:(.text+0x21c1): undefined reference to `send@16'
obj/communication.o:communication.cpp:(.text+0x21d3): undefined reference to `WSAGetLastError@0'
obj/communication.o:communication.cpp:(.text+0x240c): undefined reference to `recv@16'
obj/communication.o:communication.cpp:(.text+0x242b): undefined reference to `WSAGetLastError@0'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0x7b6): undefined reference to `inet_addr@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0x7c8): undefined reference to `gethostbyname@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0x9a6): undefined reference to `inet_addr@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0x9b8): undefined reference to `gethostbyname@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xa68): undefined reference to `inet_addr@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xa7a): undefined reference to `gethostbyname@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xb08): undefined reference to `inet_addr@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xb1a): undefined reference to `gethostbyname@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xbc8): undefined reference to `inet_addr@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xbda): undefined reference to `gethostbyname@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xc68): undefined reference to `inet_addr@4'
../development/lib/libgurux_dlms_cpp.a(GXDLMSIp4Setup.o):GXDLMSIp4Setup.cpp:(.text+0xc7a): undefined reference to `gethostbyname@4'
collect2.exe: error: ld returned 1 exit status
make: *** [bin/gurux.dlms.client.bin] Error 1
---------------------------------------------------------------

Profile picture for user Kurumi

Kurumi

4 years 9 months ago

Hi,

Hi,

You are using MinGW and it doesn't support Windows sockets. Check how to use sockets in MinGW and replace those functions (socket, closesocket, etc.).

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 10/13/2026 - 12:00
    gurux.dlms.java 4.0.97
  • Tue, 09/22/2026 - 14:02
    Gurux.DLMS.Net 9.0.2609.2201
  • Mon, 09/21/2026 - 10:18
    Gurux.DLMS.Net 9.0.2609.2101
  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202

New forum topics

  • Association refresh related issue
  • Need RJ45 pin configuration for Saral 300 and Saral 305 Secure meters
  • Query Regarding Class 63 Status Mapping Support in Gurux DLMS Python
  • Inhemeter
  • DLMS Server - Profile Generic - can't add too many items to profile generic capture object - how to set maximum profile entries
More

Who's new

  • yogibear
  • Eric@li
  • Asier Sierra
  • BlessyAnn
  • sravya.thota@m…
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin