[zeromq-dev] Errors building a DLL which includes ZeroMQ (0MQ) functionality.

Riskybiz riskybizLive at live.com
Wed Jul 17 08:49:29 CEST 2013


I'm creating a C++ DLL using Visual Studio 2012 and would like to use ZeroMQ
functionality in it.  I've basically taken the ZeroMQ example 'hwserver'
Hello World Server and adapted it into a header file for use within my DLL
(Code below).  Problem is that I get hundreds of warnings and errors when
trying to build the DLL;  the errors are repetitious referring to many
different elements of the same header files:

 

Winsock2.h ...redeclaration cannot add dllexport/dllimport...

winsock2.h  Macro redefinitions.

ws2def.h  type redefinitions

 

etc etc etc....

 

and sample errors below:

 

Warning               26           warning C4005: 'SOMAXCONN' : macro
redefinition         C:\Program Files (x86)\Windows
Kits\8.0\Include\um\winsock2.h              506         1 TestDataAccess

 

125         IntelliSense: redeclaration cannot add dllexport/dllimport to
"WSAUnhookBlockingHook" (declared at line 879 of "C:\Program Files
(x86)\Windows Kits\8.0\Include\um\winsock.h")        c:\Program Files
(x86)\Windows Kits\8.0\Include\um\WinSock2.h             2381       1
TestDataAccess

 

79           IntelliSense: expected an identifier         c:\Program Files
(x86)\Windows Kits\8.0\Include\shared\ws2def.h         414                5
TestDataAccess

 

Error      63           error C2375: 'WSAStartup' : redefinition; different
linkage            C:\Program Files (x86)\Windows
Kits\8.0\Include\um\winsock2.h              2296       1 TestDataAccess

 

 

I've already experimented with the ZeroMQ examples 'hwserver' Hello World
Server & `hwclient` Hello World Client.  I can get the exe application files
for these examples to build and run OK on my PC (Same machine as I'm using
for the DLL).

 

 

It's clear that something is significantly wrong here; does anyone know what
it could be?  Or what steps are needed to build a DLL in Visual Studio 2012
using the ZeroMQ libraries. (Note: I've used Boost libraries in the same
manner, for a DLL, without all this trouble!)

 

 

Hope you can help,

 

With thanks,

 

Riskybiz.

 

Code I'm trying to build in a DLL:

 

 

#ifndef ZMQ_COMMUNICATIONS_H//if not defined already

#define ZMQ_COMMUNICATIONS_H//then define it

 

#include <zmq.hpp>

 

void ListenOnReplySocket()

{

//  Prepare our context and socket

    zmq::context_t context (1);

    zmq::socket_t socket (context, ZMQ_REP);

    socket.bind ("tcp://*:5555");

 

while (true)

{

        zmq::message_t request;

 

        //  Wait for next request from client

        socket.recv (&request);

 

char buffer[50];

int j;

j = sprintf_s(buffer, 50, "TestDataAccess: ZMQComms: Hello");

OutputDebugStringA(buffer);

       

 

        //  Do some 'work'

        Sleep (1);

 

        //  Send reply back to client

        zmq::message_t reply (5);

        memcpy ((void *) reply.data (), "World", 5);

        socket.send (reply);

    }

}

#endif

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130717/536315e0/attachment.htm>


More information about the zeromq-dev mailing list