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 4 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, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin