Mono:DllImport 无法加载库“(null)”

发布于 2024-09-27 05:24:34 字数 964 浏览 3 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江城子 2024-10-04 05:24:34

我不完全确定,但这可能有用:

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.

方觉久 2024-10-04 05:24:34

问题是该库是 64 位的。这可以通过编译 libzmq 来修复:

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

尽管这可能会破坏使用 64 位版本的库(即通过 pyzmq 的 Python)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文