[zeromq-dev] Compiling zmq inside program
malist imap
mailing.list at manageapp.com
Wed Jan 11 15:36:25 CET 2012
Martin Sustrik kirjoitti 11.tammi.2012 kello 13.30:
> Hi Pasi,
>
>> I tried to compile zqm as a static library but it is just too much
>> work with every version. I was able to do it with older VisualStudio,
>> but with VS2010 and zmq 3.1.1 I just can't get it to work any more.
>
> What's the error you are getting?
I am unable to link _static_ zmq library to my product. I was able to do it (after huge amount of trial and error) with Visual Studio 2008 Express and zmq 2.0.x. OSX is easy, but I can't debug static library in OSX.
>
>> a) In OSX 10.7 Xcode 4.2 it seems that Xcode (or Boost) defines
>> somewhere a macro called "check". Method "check" is defined also in
>> msg.hpp and trie.hpp and I couldn't compile my app. I had to put
>> inside platform.hpp: #ifdef check #undef check #endif It this the
>> right way to deal with the problem?
>
> cpp files in libzmq project don't include Xcode or Boost headers. How come the macro is defined?
Xcode has "check" defined in AssertMacros.h. I finally found a way to fix this:
http://mateusz.loskot.net/2010/03/10/cc-macros-made-by-apple/
In Xcode project setting I have GCC_PREFIX_HEADER = prefix.pch. File prefix.pch contained only:
#include <Carbon/Carbon.h>.
I was able to compile all when I changed it to:
#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
#include <Carbon/Carbon.h>
Problem solved.
>
>> b) It seems that I have to make copies of same sources in both OSX
>> and Windows and compile sources at least once to get correct
>> platform.hpp. I would like to use exact same sources, but is it
>> possible? Do I need something else than platform.hpp?
>
> The configure step checks your system and sets the ZMQ_HAVE_* macros accordingly. Thus, on 2 different systems you have two different platform.hpp files.
So this means that I can no use _exactly_ the same sources. It is ok for me, I can update sources from git and run configure on both platforms.
>> c) To be able to compile in windows I need to change manually zmq.h
>> and zmq_utils.h from: # if defined DLL_EXPORT # define
>> ZMQ_EXPORT __declspec(dllexport) # else # define ZMQ_EXPORT
>> __declspec(dllimport) # endif to: # if defined DLL_EXPORT #
>> define ZMQ_EXPORT # else # define ZMQ_EXPORT # endif I
>> would like to have one more define (NO_ZMQ_EXPORT?), is it too much
>> trouble to change this?
>
> What would such macro mean? What is a library good for it doesn't export any symbols?
If I place zmq headers and sources (src/.hpp and .cpp files) inside my VS2010 (or Xcode project) it compiles zmq inside my app. In that case zmq is not a library and __declspec must not be defined.
>
>> d) https://github.com/zeromq/libzmq says the last change is December
>> 19, 2011. Are there any newer versions somewhere?
>
> There are several patches pending but these haven't been applied yet. What exactly are you looking for?
>
> Martin
I'm looking for XREP bug, issue LIBZMQ-304. I only use XREP so I can't continue to test 3.1.x. Following program crashes in Windows and hangs forever in OSX.
line: s_dump(worker) -> zmq_recvmsg(socket, &message, 0).
static void MA_Zmq_Test()
{
long err;
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_XREP);
err = zmq_setsockopt (worker, ZMQ_IDENTITY, "WORKER", 6);
//err = zmq_bind (worker, "ipc://rtrouter.ipc");
err = zmq_bind (worker, "tcp://127.0.0.1:5555");
void *server = zmq_socket (context, ZMQ_XREP);
err = zmq_setsockopt (server, ZMQ_IDENTITY, "SERVER", 6);
//err = zmq_connect (server, "ipc://rtrouter.ipc");
err = zmq_connect (server, "tcp://127.0.0.1:5555");
//zmq_sleep (1); // sleep in seconds
#if VERSIONWIN
Sleep (1 * 1000);
#else
sleep (1);
#endif
s_sendmore (server, (char *)"WORKER");
s_sendmore (server, (char *)"");
s_send (server, (char *)"send to worker");
s_dump (worker);
s_sendmore (worker, (char *)"SERVER");
s_sendmore (worker, (char *)"");
s_send (worker, (char *)"send to server");
s_dump (server);
zmq_close(worker); // must close sockts or zmq_term will hang
zmq_close(server); // must close sockts or zmq_term will hang
zmq_term (context);
}
--
Regards,
Pasi Mankinen
Finland
More information about the zeromq-dev
mailing list