필터 지우기
필터 지우기

testing MATLAB dll using mbuild

조회 수: 8 (최근 30일)
Mohammed Samdani
Mohammed Samdani 2012년 1월 20일
Hi,
I want to verify dll generated in MATLAB. Hence I had referred this link below http://blogs.mathworks.com/loren/2011/04/21/deploying-multiple-c-shared-libraries/
my function signarure in matlab is function abc(TName, Flag, varargin)
to run this function from MATLAB command prompt i give his command as below
abc('parm1', 'param2', 'param3', 'path to file 1', 'path to file 2')
I want to know how can I declare the mwArray in .cpp file. I had tried
mwArray param1;
mwArray param2;
mwArray input(1, 3, mxCELL_CLASS);
mwArray arg1('param3');
mwArray arg2('path to fiel 1');
mwArray arg3(path to field 2');
input.Get(1,1).Set(arg1);
input.Get(1,2).Set(arg2);
input.Get(1,3).Set(arg3);
with this I get errors when I execute mbuild command. any help ?
is it possible to single step(debug)
Thanks in advance
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2012년 1월 20일
Please paste the exact errors you receive from mbuild.

댓글을 달려면 로그인하십시오.

답변 (2개)

Kaustubha Govind
Kaustubha Govind 2012년 1월 20일
This page seems to suggest that MATLAB Compiler "creates several overloaded methods that implement the MATLAB functions. Each of these overloaded methods corresponds to a call to the generic MATLAB function with a specific number of input arguments". So you could try passing them in as 5 arguments:
mxArray *in1 = mxCreateString("param1");
mxArray *in2 = mxCreateString("param2");
mxArray *in3 = mxCreateString("param3");
mxArray *in4 = mxCreateString("path to file 1");
mxArray *in5 = mxCreateString("path to file 2");
Also, you need mxArray, not mwArray.
  댓글 수: 1
Mohammed Samdani
Mohammed Samdani 2012년 1월 23일
Hi Kaustubha,
I got the below error message after implementing your solution
error c2660: 'abc': function does not take 7 arguments
error c2660: 'xyz': function does not take 1 arguments
abc and xyz are 2 functions in matlab which are converted to dll(library).
function abc() calls function xzy()
Signature for function abc() is
function abc(tName, Flag, varargin)
signature of function xyz() is
function [success, errorMsg, varargout] = xyz(functionName, bFlag, varargin)
I am following steps as give in below link.
http://blogs.mathworks.com/loren/2011/04/21/deploying-multiple-c-shared-libraries/
// Must declare all MATLAB data types after initializing the
// application and the library, or their constructors will fail.
mxArray *in1 = mxCreateString("Param1");
mxArray *in2 = mxCreateString("Param2");
mxArray *in3 = mxCreateString("Parma3");
mxArray *in4 = mxCreateString("Path to file1");
mxArray *in5 = mxCreateString("path to file 2");
mwArray test_Dll; //is .cpp file test_Dll.cpp
// Initialization succeeded
Testing_auCal_appCmdLine(1, test_Dll *in1, *in2, *in3, *in4, *in5);
// had also tried
//Testing_auCal_appCmdLine(*in1, *in2, *in3, *in4, *in5);
// call the library xyz
xyz(abc);
// Wait for the user to close the figure
mclWaitForFiguresToDie(NULL);
Requesting your suggestions. Wanted to know if my approach is correct. Where can I find mor information. on mxArray etc.
Thanks

댓글을 달려면 로그인하십시오.


Mohammed Samdani
Mohammed Samdani 2012년 1월 24일
http://blogs.mathworks.com/loren/2011/04/21/deploying-multiple-c-shared-libraries/ I used the example in above link and modified to accept varargin and used solution provided in below link http://www.mathworks.com/matlabcentral/answers/22031-mwarray-varargin-initialize and
mwArray input(1, 2, mxCELL_CLASS); input.Get(1,1).Set(atof(av[1])); input.Get(1,2).Set(atof(av[2])); input.Get(1,1).Set(width); input.Get(1,2).Set(limit); mwArray fractal1; // Initialization succeeded. Generate the image.
mandelbrot(1, fractal1, input);
it worked for me.
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2012년 1월 25일
Great! Good to know you were able to resolve the issue.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by