[zeromq-dev] Errors creating a DLL including ZeroMQ
Riskybiz
riskybizLive at live.com
Thu Jul 18 16:29:21 CEST 2013
Shon,
the link you provided:
http://stackoverflow.com/questions/1372480/c-redefinition-header-files was
golden! It said, amongst other things to add this line:
#define _WINSOCKAPI_ //to stop windows.h including winsock.h
I extrapolated that to this line, as my errors related to winsock2.h:
#define _WINSOCK2API_ //stops windows.h including winsock2.h
And bingo, success, the DLL file built without errors and I was able to
demonstrate ZeroMQ client-server communications.
Many thanks & all the best,
Riskybiz.
-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org
[mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of
zeromq-dev-request at lists.zeromq.org
Sent: 18 July 2013 11:00
To: zeromq-dev at lists.zeromq.org
Subject: zeromq-dev Digest, Vol 67, Issue 18
Send zeromq-dev mailing list submissions to
zeromq-dev at lists.zeromq.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
or, via email, send a message with subject or body 'help' to
zeromq-dev-request at lists.zeromq.org
You can reach the person managing the list at
zeromq-dev-owner at lists.zeromq.org
When replying, please edit your Subject line so it is more specific than
"Re: Contents of zeromq-dev digest..."
Today's Topics:
1. Re: Errors creating a DLL including ZeroMQ (Riskybiz)
2. Re: Errors creating a DLL including ZeroMQ (Shon Love)
----------------------------------------------------------------------
Message: 1
Date: Wed, 17 Jul 2013 15:02:51 +0100
From: Riskybiz <riskybizLive at live.com>
Subject: Re: [zeromq-dev] Errors creating a DLL including ZeroMQ
To: <zeromq-dev at lists.zeromq.org>
Message-ID: <DUB124-DS14947C8750233471E83946BE610 at phx.gbl>
Content-Type: text/plain; charset="us-ascii"
Shon,
are you able to expand on that please?
"Hey,
I'm guessing you need to link your dll against the 'ws2_32.lib' library.
Thanks,
Shon"
I found the WS_32.lib file here:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\WS_32.lib
And tried to link it under Project Properties like so:
Linker->General->Additional Library Dependencies-> C:\Program Files
(x86)\Boost\boost_1_53_0\stage\lib;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\WS_32.lib;
C:\zeromq-3.2.3\lib\Win32
Also tried:
Linker->Input->AdditionalDependencies-> C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.1A\Lib\WS2_32.lib
C:\zeromq-3.2.3\lib\Win32\libzmq.lib
Still getting a mass of errors on trying to build.
Thanks,
RiskyBiz
____________________________________________________________________________
_____________________________________________________________________
Date: Tue, 16 Jul 2013 15:30:30 -0600
From: Shon Love <slove at fatpot.com>
Subject: Re: [zeromq-dev] Errors creating a DLL including ZeroMQ
libraries
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
Message-ID:
<CAPDi4c4CLhe9v2hWUEHEZiiv82mEaFgSA9g2MpkkKEKpatVZdA at mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
Hey,
I'm guessing you need to link your dll against the 'ws2_32.lib' library.
Thanks,
Shon
On Tue, Jul 16, 2013 at 3:18 PM, Riskybiz <riskybizLive at live.com> wrote:
> I?m creating a C++ DLL using Visual Studio 2012 and would like to use
> ZeroMQ libraries 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****
>
> ** **
>
> ** **
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
--
Shon C. Love
Programmer
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130716/6c817207/a
ttachment-0001.htm
------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130717/f3b32a00/a
ttachment.html
------------------------------
Message: 2
Date: Wed, 17 Jul 2013 08:41:55 -0600
From: Shon Love <slove at fatpot.com>
Subject: Re: [zeromq-dev] Errors creating a DLL including ZeroMQ
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
Message-ID:
<CAPDi4c5g-WNOk4fsq64J7=LY6GAHgD5i_TFrENK9d5o5DqxKWA at mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
Hey,
Sorry - the linking may be necessary, but those are compiler errors,
aren't they :)
Searching on google for some of the errors brought up an interesting
discussion on stackoverflow.com:
http://stackoverflow.com/questions/1372480/c-redefinition-header-files
There may be some useful hints in those answers.
Thanks,
Shon
On Wed, Jul 17, 2013 at 8:02 AM, Riskybiz <riskybizLive at live.com> wrote:
> Shon,****
>
> are you able to expand on that please?****
>
> ** **
>
> ?Hey,****
>
> ** **
>
> I'm guessing you need to link your dll against the 'ws2_32.lib' library.
> ****
>
> ** **
>
> Thanks,****
>
> Shon?****
>
> ** **
>
> I found the WS_32.lib file here:****
>
> ** **
>
> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\WS_32.lib****
>
> ** **
>
> And tried to link it under Project Properties like so:****
>
> ** **
>
> Linker->General->Additional Library Dependencies-> C:\Program Files
> (x86)\Boost\boost_1_53_0\stage\lib;****
>
> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\WS_32.lib;****
>
> C:\zeromq-3.2.3\lib\Win32****
>
> ** **
>
> Also tried:****
>
> ** **
>
> Linker->Input->AdditionalDependencies-> C:\Program Files
> Linker->Input->AdditionalDependencies-> (x86)\Microsoft
> SDKs\Windows\v7.1A\Lib\WS2_32.lib****
>
> C:\zeromq-3.2.3\lib\Win32\libzmq.lib****
>
> ** **
>
> Still getting a mass of errors on trying to build.****
>
> ** **
>
> Thanks,****
>
> ** **
>
> RiskyBiz****
>
> ** **
>
>
> ______________________________________________________________________
> ______________________________________________________________________
> _____
> ****
>
> ** **
>
> Date: Tue, 16 Jul 2013 15:30:30 -0600****
>
> From: Shon Love <slove at fatpot.com>****
>
> Subject: Re: [zeromq-dev] Errors creating a DLL including ZeroMQ****
>
> libraries****
>
> To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>****
>
> Message-ID:****
>
> <
> CAPDi4c4CLhe9v2hWUEHEZiiv82mEaFgSA9g2MpkkKEKpatVZdA at mail.gmail.com>***
> *
>
> Content-Type: text/plain; charset="windows-1252"****
>
> ** **
>
> Hey,****
>
> ** **
>
> I'm guessing you need to link your dll against the 'ws2_32.lib' library.
> ****
>
> ** **
>
> Thanks,****
>
> Shon****
>
> ** **
>
> ** **
>
> On Tue, Jul 16, 2013 at 3:18 PM, Riskybiz <riskybizLive at live.com>
> wrote:**
> **
>
> ** **
>
> > I?m creating a C++ DLL using Visual Studio 2012 and would like to
> > use **
> **
>
> > ZeroMQ libraries 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********
>
> >** **
>
> > ** ******
>
> >** **
>
> > ** ******
>
> >** **
>
> > _______________________________________________****
>
> > zeromq-dev mailing list****
>
> > zeromq-dev at lists.zeromq.org****
>
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev****
>
> >** **
>
> >** **
>
> ** **
>
> ** **
>
> --****
>
> Shon C. Love****
>
> Programmer****
>
> -------------- next part --------------****
>
> An HTML attachment was scrubbed...****
>
> URL:
> http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130716/6c81
> 7207/attachment-0001.htm
> ****
>
> ** **
>
> ------------------------------****
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
--
Shon C. Love
Programmer
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130717/b4c330e0/a
ttachment-0001.htm
------------------------------
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
End of zeromq-dev Digest, Vol 67, Issue 18
******************************************
More information about the zeromq-dev
mailing list