【问题标题】:Invalid IL code when calling a native linux library from a .NET application running under mono in CentOS从 CentOS 中单声道下运行的 .NET 应用程序调用本机 linux 库时,IL 代码无效
【发布时间】:2018-07-20 17:56:59
【问题描述】:

我正在尝试在多平台环境中使用英特尔 MKL 库。我的 DllImports 和包装类在 .NET/Windows 下工作。但是,当我将它移植到 CentOS 时,我得到“无效的 IL 代码”。

我已更改 DLLImports 以包含 Linux 版本的 MKL(一个 .so 库)。我添加了 LD_LIBRARY_PATH 环境变量。尽管如此,无论库是否存在,错误都不会改变。而且我没有收到 DLLNotFound 错误,我收到了无效的 IL 错误。

下面我粘贴我的窗口,工作 dllimport 语句。

[DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
    internal static extern int DftiCreateDescriptor(
        ref IntPtr handle_descriptor,
        int precision,
        int domain,
        int dime,
        int size
    );

现在这就是我想出的 linux

[DllImport("libmkl_rt.so", CallingConvention = CallingConvention.Cdecl)]
    private static extern int DftiCreateDescriptor(
        ref IntPtr handle_descriptor,
        int precision,
        int domain,
        int dime,
        int size
    );

【问题讨论】:

    标签: .net linux mono dllimport


    【解决方案1】:

    最终通过不使用 __arg_list 并使用 Mono ".config" 文件解决了这个问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 2021-01-03
      • 2021-03-03
      • 1970-01-01
      • 2011-05-07
      • 1970-01-01
      • 2015-03-29
      相关资源
      最近更新 更多