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. Server On C

Server on C

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 AlexKuk , 21 June, 2022
Forums
Gurux.DLMS

Hi,

I can't compile GuruxDLMSSimpleServerExample.

That's what I've got

main.c: In function 'svr_InitObjects':
main.c:70:38: warning: passing argument 2 of 'oa_attach' from incompatible pointer type [-Wincompatible-pointer-types]
oa_attach(&settings->base.objects, ALL_OBJECTS, sizeof(ALL_OBJECTS) / sizeof(ALL_OBJECTS[0]));
^~~~~~~~~~~
In file included from ../include/dlmssettings.h:42:0,
from main.c:1:
../include/objectarray.h:50:10: note: expected 'gxObject ** {aka struct <anonymous> **}' but argument is of type 'const gxObject ** {aka const struct <anonymous> **}'
void oa_attach(
^~~~~~~~~
collect2.exe: error: ld returned 1 exit status

In main.c i copied the code from your examples from README.

How can I fix it?

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

What compiler you are using? I just try this with Visual Studio 2022 and it worked like expected.

Did you use this example?
https://github.com/Gurux/GuruxDLMS.c/tree/master/GuruxDLMSSimpleServerE…

BR,
Mikko

AlexKuk

3 years 11 months ago

I use gcc compiler .

I use gcc compiler .
Yes, that example.

AlexKuk

3 years 11 months ago

okay, I can compile it in VS,

okay, I can compile it in VS, now I need to get .so file, when I do it with gcc -fPIC -shared -o server.so main.c I've got:

main.c: In function 'serialPortThread':
main.c:2693:24: error: 'ERROR_IO_PENDING' undeclared (first use in this function)
if (ret != ERROR_IO_PENDING)
^~~~~~~~~~~~~~~~
main.c:2693:24: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'com_setCommState':
main.c:2976:24: error: 'ERROR_INVALID_FUNCTION' undeclared (first use in this function)
if (err != ERROR_INVALID_FUNCTION)
^~~~~~~~~~~~~~~~~~~~~~

Can I do it somehow?

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

I'll check this tomorrow with gcc (Debian 8.3.0-6) 8.3.0.

BR,
Mikko

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

This is solved. For some reason, fcntl include was removed, and that cause this.
#include <fcntl.h>

Get the latest version.

BR,
Mikko

AlexKuk

3 years 11 months ago

Could you tell me wich

Could you tell me wich command do you use to build the *.so file?
Cuz I use "gcc -fPIC -shared -o server.so main.c". I guess you may use "make ...".
And when I try to use make I get:
$ make
Assembler messages:
Fatal error: can't create obj/getopt.o: No such file or directory
make: *** [makefile:30: obj/getopt.o] Error 1

I'll write more about the project I'm making.
I have a device on Linux OS, and I'm a python software developer, actually I'm a noob in C, so my goal is to run your C server inside of mine python code. I just need something to send my data via DLMS/COSEM.
Maybe you could give me some advice or solution with those details.

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

You need to create the obj and bin folders. Run those commands.

mkdir obj
mkdir bin

BR,
Mikko

AlexKuk

3 years 11 months ago

Okay, we'd created .so.

Okay, we'd created .so.
But to work I also need to create .dll. So, when I try to do in I get:

Severity Code Description Project File Line Suppression State
Error (active) E0167 argument of type "unsigned short" is incompatible with parameter of type "DLMS_OBJECT_TYPE" DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 2187
Error (active) E0513 a value of type "int" cannot be assigned to an entity of type "DLMS_ERROR_CODE" DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 1756
Error (active) E0513 a value of type "short" cannot be assigned to an entity of type "DLMS_OBJECT_TYPE" DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 1384
Error (active) E0513 a value of type "int" cannot be assigned to an entity of type "DLMS_ERROR_CODE" DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 2028
Error (active) E0513 a value of type "int" cannot be assigned to an entity of type "DLMS_ERROR_CODE" DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 2035
Error (active) E0513 a value of type "unsigned char" cannot be assigned to an entity of type "DLMS_DATA_TYPE" DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 343
Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source? DLMS_Server_2 C:\Users\Kukachev\source\repos\DLMS_Server\GuruxDLMSSimpleServerExample\src\main.cpp 3342

Could you tell me how to fix this, or maybe give me some checklist I need to follow to create a .dll?

P.S.
For .dll creating I use VS 2022, I create a proj with .dll library settings.

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

Are you using C or C++? At first, you were using ANSI C, but now you are using C++.
I did build both with VS 2022 and both worked without problems.

BR,
Mikko

AlexKuk

3 years 11 months ago

I used C but yesterday I

I used C but yesterday I tryied with C++ too. It works when I'm trying to compilate it as a server proj, but when I'm trying to build a dll it doesn't.

Image
Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

Your UI looks Like Visual Studio Code, not Visual Studio 2022. Am I right?

You need to compile development project as a DLL. Then you need to link that for GuruxDLMSSimpleServerExample. GuruxDLMSSimpleServerExample is an exe.

BR,
Mikko

AlexKuk

3 years 11 months ago

No, my UI is Visual Studio

No, my UI is Visual Studio 2022.

So, to development as a DLL I have to create some file.cpp and export there all the functions I need. Something like this?

Profile picture for user Kurumi

Kurumi

3 years 11 months ago

Hi,

Hi,

No. If you just open the server example you should be able to build the example right away. I just tested this with VS 2022 and it worked without problems.

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