testing MATLAB dll using mbuild

4 views (last 30 days)
Mohammed Samdani
Mohammed Samdani on 20 Jan 2012
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 Comment
Kaustubha Govind
Kaustubha Govind on 20 Jan 2012
Please paste the exact errors you receive from mbuild.

Sign in to comment.

Answers (2)

Kaustubha Govind
Kaustubha Govind on 20 Jan 2012
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 Comment
Mohammed Samdani
Mohammed Samdani on 23 Jan 2012
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

Sign in to comment.


Mohammed Samdani
Mohammed Samdani on 24 Jan 2012
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 Comment
Kaustubha Govind
Kaustubha Govind on 25 Jan 2012
Great! Good to know you were able to resolve the issue.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!