Mono:DllImport 无法加载库“(null)”
我正在尝试使用 C# ZeroMQ 绑定。然而,在 Mono 2.8 和 OSX 10.6.4 上,当我尝试运行示例应用程序时,出现 DLLImport 错误。具体来说:
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
这个函数很简单:
[DllImport("libzmq", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr zmq_init(int io_threads);
当我使用 MONO_LOG_LEVEL=debug 时,mono 显示它正在寻找 libzmq 但不断失败,例如:
Mono: DllImport loading library: './libzmq.dylib'.
Mono: DllImport error loading library '(null)'.
我尝试将 libzmq.dylib 移动到本地文件夹并设置 libzmq.dll.config 文件,均无济于事。
Mono 无法找到位于 /usr/local/lib 中的 libzmq.dylib 是否有明显的原因?为什么错误会变成“(null)”?
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)"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不完全确定,但这可能有用:
http://www.mono -project.com/Interop_with_Native_Libraries#Mac_OS_X_Framework_and_.dylib_Search_Path
本质上,您可能需要确保 DYLD_FALLBACK_LIBRARY_PATH 设置为包含 dylib 的位置。
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.
问题是该库是 64 位的。这可以通过编译 libzmq 来修复:
尽管这可能会破坏使用 64 位版本的库(即通过 pyzmq 的 Python)。
The problem is that the library is 64-bit. This can be fixed by compiling libzmq with:
Although this may break libraries that use the 64 bit version (i.e. Python via pyzmq).