[zeromq-dev] FYI: MSVC2012 and 0mq

Dimiter 'malkia' Stanev malkia at gmail.com
Wed Sep 5 20:40:25 CEST 2012

On 9/5/12 8:05 AM, Steven McCoy wrote:
> I have MSVC 2012 Premium today thus looking to package multi-compiler
> library packages.  Initially I'm running with MSVC 2008, 2010, and 2012.
>   I don't think 2005 works with 0mq but those users along side 2003 can
> hack something out themselves: actually found a 2003 user this week.
> --
> Steve-o
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

I'm using the Windows WDK 7.1 (7600) to build ZeroMQ, this links to 
MSVCRT.DLL and all other libraries that I compile target it too.

I had to add these flags to CL (dynamic "C" MSVCRT, but static "C++" 
runtime lib):
	 -Dssize_t=SSIZE_T -D_STL70_=1 -D_STATIC_CPPLIB=1
And for the Linker (the obj file below helps targeting MSVCRT.DLL on 
older systems - in this case back to Windows 2003 Server, for x86 there 
is even msvcrt_win2000.obj):
	msvcrt_win2003.obj ntstc_msvcrt.lib

I also compile OpenPGM as DLL, from the static lib, by looking at what 
it exports as normal "C" symbols and making .DEF file out of it.

Here is my compile, but I haven't updated it in 4 months, would do an 
update soon


The actual batch files that compile zmq/pgm are here, but they require 
cygwin (sed/grep/etc.), and the WDK.


FYI: I've even started a test project multi_msvcrt to test how well one 
can combine different CRT's and what can be exchanged between them - 
well as I expected - almost nothing - memory allocated from one CRT 
(malloc/new) can't be freed by another... Somehow I'm getting successful 
fileno() on file open from one CRT to another, and if I have time I'll 
be adding more tests for fun.


For now I'm sticking to MSVCRT. Mingw also targets it, and since there 
are projects that are easier to compile with MINGW than MSVC, I would 
stick my guns to that.

It might be even possible to target MSVCRT.DLL with recent compiler like 
VS2010, but not VS2012 - nothing generated from it runs on XP.

The idea is to find this "msvcrt_winXXX.obj" from the WDK and use it 
VS2010. WDK itself comes with a compiler close to VS2008.

Then again, since ZMQ and CrossRoads have a wonderful API, not exposing 
any "C" or "C++" runtime objects/functions it can be compiled with 
static CRT, in effect linking only to KERNEL32.DLL, WS*.DLL, etc, just 
taking a little more memory.

More information about the zeromq-dev mailing list