【问题标题】:Making a huge library from a lots of dlls and use it separately从大量的 dll 中创建一个巨大的库并单独使用它
【发布时间】:2012-10-01 22:17:03
【问题描述】:

目前我在 C# 程序中使用 math kernel library dll mkl_rt.dll 中的一些功能,所以我有

using mkl;

namespace mklDirect
{
    int LAPACK_ROW_MAJOR = 101;
    int LAPACK_COL_MAJOR = 102;
    int n, m, lda;
    n = 3;m = 3;
    lda = n;
    int ldu = m;
    int ldvt = n;
    Double[] superb = new Double[m - 1];
    Double[] s = new Double[n];
    Double[] u = new Double[n * n];
    Double[] vt = new Double[n * n];
    Double[] A = new Double[9]
    {
                         8.79,  9.93,  9.83,
                         6.11,  6.91,  5.04,
                         -9.15, -7.93, 4.86
     };
     Char a1 = 'A';
     Char a2 = 'A';
     int mat_order = LAPACK_ROW_MAJOR;
     int info = 0;
     double[] work1 = new double[1];
     MKLImports.LAPACKE_dgesvd(mat_order, a1, a2, m, n, A, lda, s, u, ldu, vt, ldvt, superb);

     //PRINT RESULT


}  


namespace mkl
{
        internal sealed class MKLImports
        {
            private  MKLImports()
            {                 
            }

        [DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
            internal static extern void LAPACKE_dgesvd(
                  int matrix_order,
                  char a1,
                  char a2,
                  int m,
                  int n,
                 [In, Out] double[] input_matrix,
                  int lda,
                 [In, Out] double[] s,
                 [In, Out] double[] u,
                  int ldu,
                 [In, Out] double[] vt,
                  int ldvt,
                  double[] superb
          );
        }
}

我想继续在命名空间 mkl 中添加函数,然后在另一个文件中使用这些函数。我不知道这是否会产生副作用或最好的方法是什么。在代码中,我加载了 dll,从 mkl 和其他 dll 中创建了一个巨大的库。

【问题讨论】:

    标签: c# dll shared-libraries


    【解决方案1】:

    您只是想创建一个互操作文件吗?有一些方法可以为您生成完整的互操作文件,这些文件会自动生成这样的代码供您随意使用。

    http://msdn.microsoft.com/en-us/library/tw4zwhbe.aspx

    http://msdn.microsoft.com/en-us/library/aa302338.aspx

    http://msdn.microsoft.com/en-us/library/1w557csx.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-23
      • 1970-01-01
      • 2012-02-23
      相关资源
      最近更新 更多