clrzmq icon indicating copy to clipboard operation
clrzmq copied to clipboard

libzmq for ZeroMQ for Mono on Windows?

Open dsblank opened this issue 10 years ago • 9 comments

Hello, I have successfully built clrzmq/src/ZeroMQ on Windows for Mono, but I can't figure out what libzmq.dll nor where to put it. Any suggestions?

dsblank avatar Mar 03 '14 12:03 dsblank

Windows Windows/System32 Windows/SysWOW64

mafairnet avatar Mar 03 '14 13:03 mafairnet

Which libzmq.dll will work? I can put different versions of libzmq.dll in the directory of the .exe, but none appear to be the correct libzmq.dll. Which version?

dsblank avatar Mar 03 '14 13:03 dsblank

The correct one it's depending on your OS architecture (x86 -> 32 bits, x64 ->64bits)

mafairnet avatar Mar 03 '14 13:03 mafairnet

Thanks for attempting to help, but I cannot make this work. I think it is a problem in getting the correct version of the libzmq.dll (2.2.0?). I get an error if I attempt to refer to:

ZeroMQ.ZmqVersion.Current

SystemError: An exception was thrown by the type initializer for ZeroMQ.Interop.LibZmq

That suggests that clrzmq is finding the libzmq.dll, but it is not the correct version for ZeroMQ for Mono.

dsblank avatar Mar 03 '14 13:03 dsblank

Do you need additional information?

dsblank avatar Mar 04 '14 08:03 dsblank

Some additional detail: we're using the same managed DLL (with the ZeroMQ namespace, from the Mono folder) on Linux, Mac, and Windows. We have the correct low-level libraries for Mac, and Linux (and everything works fine), but have not been able to find the correct low-level libraries for Windows for that particular managed DLL. Any ideas?

dsblank avatar Mar 13 '14 14:03 dsblank

I think I have come to the conclusion that you can't use Mono on Windows with this code. Why do I want to use Mono on Windows? Because we have one code base for all platforms. Here is the problem:

If you build src\clrzmq.Mono.sln, and then compile and run this program with Mono on Windows:

using System;
using ZeroMQ;
namespace TestZMQ
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Console.WriteLine ("Hello World! " + ZeroMQ.ZmqVersion.Current);
        }
    }
}

You get:

Unhandled Exception: System.TypeInitializationException: An exception was thrown
 by the type initializer for ZeroMQ.Interop.LibZmq ---> System.TypeInitializatio
nException: An exception was thrown by the type initializer for Errno ---> Syste
m.ArgumentOutOfRangeException: Current platform doesn't support this value.
Parameter name: value
EADDRINUSE
  at Mono.Unix.Native.NativeConvert.ThrowArgumentException (System.Object value)
 [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.8\mcs\class\Mono.Pos
ix\Mono.Unix.Native\NativeConvert.generated.cs:21
  at Mono.Unix.Native.NativeConvert.FromErrno (Errno value) [0x0000e] in C:\cygw
in\tmp\monobuild\build\BUILD\mono-2.10.8\mcs\class\Mono.Posix\Mono.Unix.Native\N
ativeConvert.generated.cs:197
  at ZeroMQ.Interop.Platform+Errno..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at ZeroMQ.Interop.LibZmq..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at ZeroMQ.ZmqVersion.GetCurrentVersion () [0x00000] in <filename unknown>:0
  at System.Lazy`1[ZeroMQ.ZmqVersion].InitValue () [0x0014f] in C:\cygwin\tmp\mo
nobuild\build\BUILD\mono-2.10.8\mcs\class\corlib\System\Lazy.cs:155
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An except
ion was thrown by the type initializer for ZeroMQ.Interop.LibZmq ---> System.Typ
eInitializationException: An exception was thrown by the type initializer for Er
rno ---> System.ArgumentOutOfRangeException: Current platform doesn't support th
is value.
Parameter name: value
EADDRINUSE
  at Mono.Unix.Native.NativeConvert.ThrowArgumentException (System.Object value)
 [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.8\mcs\class\Mono.Pos
ix\Mono.Unix.Native\NativeConvert.generated.cs:21
  at Mono.Unix.Native.NativeConvert.FromErrno (Errno value) [0x0000e] in C:\cygw
in\tmp\monobuild\build\BUILD\mono-2.10.8\mcs\class\Mono.Posix\Mono.Unix.Native\N
ativeConvert.generated.cs:197
  at ZeroMQ.Interop.Platform+Errno..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at ZeroMQ.Interop.LibZmq..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at ZeroMQ.ZmqVersion.GetCurrentVersion () [0x00000] in <filename unknown>:0
  at System.Lazy`1[ZeroMQ.ZmqVersion].InitValue () [0x0014f] in C:\cygwin\tmp\mo
nobuild\build\BUILD\mono-2.10.8\mcs\class\corlib\System\Lazy.cs:155
Press any key to continue . . .

dsblank avatar Mar 15 '14 19:03 dsblank

Found the issue:

There was a confusion between MONO and UNIX flags:

in the file SocketProxy.cs:

line 398, change UNIX to MONO line 407, change UNIX to MONO

dsblank avatar Mar 15 '14 19:03 dsblank

I corrected this issue using Visual Studio 2015 by adding Reference to the project ZeroMQ.VS instead of the release ZeroMQ.dll

markwkjr avatar Aug 13 '15 20:08 markwkjr