Why does my C++ program crash when I try displaying an mwArray as a string using the C++ Utility Library of MATLAB Compiler 4.0 (R14)?

3 views (last 30 days)
I am attempting to display an mwArray in my C++ code as a string. For example, I might use:
mclInitializeApplication(NULL,0);
mwArray x(3);
cout << "X = " << x << endl;
mclTerminateApplication();
However, this code causes my application to crash.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This problem has been fixed in MATLAB Compiler 4.1 (R14SP1). If you are using a previous version, read the following:
We have verified that there is a bug in the C++ Utility Library of MATLAB Compiler 4.0 (R14) in the way that the toString method of an mwArray is handled. To work around this issue, generate a shared library from an M-function that will allow you to display the mwArray as a string. For example, you might use the following in the C++ program:
mwArray x(3);
my_disp(x);
where my_disp is a C++ shared library generated from the following M-function:
function my_disp(x)
disp(x);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!