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 6 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

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Possible memory leak in file dlms.c, getCompactArrayItem(), getCompactArrayItem2()
  • Official Gurux.DLMS.Client.Example.Net fails during High GMAC secure association (Invalid PDU), while Gurux Director connects successfully
  • gurux_dlms.GXDateTime.GXDateTime object Error in Python
  • T_APPL_DATA_LN_N1 subtest 3 fails on an LN-only server regardless of the response to a non-existing-object GET
  • Version mismatch between Gurux.DLMS 9.x and Gurux.Common/Gurux.Serial 8.x
More

Who's new

  • isabelbf3
  • xkQAHLRbrboWkI…
  • RBCLQVpfdDeeYPPbKksI
  • eZDLCKpzJAzARY…
  • RicardoNoula
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin