[zeromq-dev] List Guidelines and Project/Source modifications - Windows/MSVC

john skaller skaller at users.sourceforge.net
Thu Jan 19 17:05:27 CET 2012


On 20/01/2012, at 1:39 AM, rafael at soscpd.net wrote:
[]

OUCH! I see this in zmq.h:

/*  Handle DSO symbol visibility                                             */
#if defined _WIN32
#   if defined DLL_EXPORT
#       define ZMQ_EXPORT __declspec(dllexport)
#   else
#       define ZMQ_EXPORT __declspec(dllimport)
#   endif
#else
#   if defined __SUNPRO_C  || defined __SUNPRO_CC
#       define ZMQ_EXPORT __global
#   elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
#       define ZMQ_EXPORT __attribute__ ((visibility("default")))
#   else
#       define ZMQ_EXPORT
#   endif
#endif

This is seriously bugged. You may not use the name DLL_EXPORT.
You must use a command line macro name specific to the library!
For example ZMQ_DLL_EXPORT.

Actually the names are confused. It should read like this:


// Add any other platform stuff as above
// This code is invariant
#if !defined(FLX_STATIC_LINK) && FLX_WIN32
#define FLX_EXPORT __declspec(dllexport)
#define FLX_IMPORT __declspec(dllimport)
#else
#define FLX_EXPORT
#define FLX_IMPORT
#endif

Now you do this:

#ifdef BUILD_ZMQ
#define ZMQ_EXTERN FLX_EXPORT
#else
#define ZMQ_EXTERN FLX_IMPORT
#endif

You code is marked ZMQ_EXTERN, and you use BUILD_ZMQ
on the command line.
 
Ok, so you've messed up the name for ZMQ_EXTERN and called
is ZMQ_EXPORT, but that has no semantic impact.

Using the name DLL_EXPORT is the problem, you absolutely must not do this.
As above, you can try ZMQ_DLL_EXPORT, or by Felix protocol, BUILD_ZMQ.
Note that the Felix protocol starts with BUILD_ not with ZMQ, because the symbol
is universal (across ALL C libraries on the internet). What actually matters
is that the symbol is universally unique to ZMQ.

Using DLL_EXPORT won't impact building ZMQ.DLL, it will impact the
building of any other library that **uses** zmq and has to import it,
and itself also uses DLL_EXPORT: in that case all the zmq symbols
get marked export too, but they're undefined: they should have been import.

--
john skaller
skaller at users.sourceforge.net







More information about the zeromq-dev mailing list