简体   繁体   中英

Import c++ DLL to c#

Please help me with DLLImpot in c#. I have DLL, analysed it with DLL Export Viewer, this class method is shown:

public: static float * __cdecl Evaluator::calculateLM(float *,float *,int,int,float *,float *)

I just can't figure out how to DllImport it into c#.

Finally figured it out.

[DllImport("LMModelSolve.dll",
            EntryPoint = "?calculateLM@Evaluator@@SAPAMPAM0HH00@Z",
            CallingConvention = CallingConvention.Cdecl)
        ]
        static extern IntPtr calculateLM(float[] x, float[] y, int n, int iterations, float[] lower, float[] upper);

And to call and get result:

IntPtr res = calculateLM(x, y, ndata, 200, lower, upper);
            float[] resultVertices = new float[4];
            Marshal.Copy(res,resultVertices,0,4);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM