tags:

views:

31

answers:

2

I'm trying to use the C# ZeroMQ bindings. However on Mono 2.8 and OSX 10.6.4, when I try to run an example application, I get a DLLImport error. Specifically:

Unhandled Exception: System.DllNotFoundException: libzmq
  at (wrapper managed-to-native) ZMQ/C:zmq_init (int)
  at ZMQ+Context..ctor (Int32 io_threads) [0x00000] in <filename unknown>:0 
  at local_lat.Main (System.String[] args) [0x00000] in <filename unknown>:0

This function is simply:

    [DllImport("libzmq", CallingConvention = CallingConvention.Cdecl)]
    public static extern IntPtr zmq_init(int io_threads);

When I use MONO_LOG_LEVEL=debug, mono shows it looking for libzmq but continually failing with things like:

Mono: DllImport loading library: './libzmq.dylib'.
Mono: DllImport error loading library '(null)'.

I've tried moving the libzmq.dylib to the local folder and setting up a libzmq.dll.config file, both to no avail.

Is there an obvious reason why Mono is failing to find libzmq.dylib, which is located in /usr/local/lib? And why does the error become "(null)"?

A: 

I'm not totally sure, but this might be useful reading:

http://www.mono-project.com/Interop_with_Native_Libraries#Mac_OS_X_Framework_and_.dylib_Search_Path

Essentially, you probably need to make sure DYLD_FALLBACK_LIBRARY_PATH is set to a location containing your dylib.

Sandy
A: 

The problem is that the library is 64-bit. This can be fixed by compiling libzmq with:

./configure CFLAGS="-O -arch i386" CXXFLAGS="-O -arch i386" LDFLAGS="-arch i386" --disable-dependency-tracking

Although this may break libraries that use the 64 bit version (i.e. Python via pyzmq).

Tristan