Can't run executable created by MCC, of m-code containing EML directives.

1 view (last 30 days)
Hi,
My project is intended to be compiled by mcc into an executable, on linux using version r2009b, though I'm having the following problem with later versions as well.
I'm trying to start using the embedded matlab compiler (emlmex) on some of its m-files for improving running time, and it seems to work well when run from the matlab command line, without further compilation by mcc.
Some of the functions I have are used both as m-files called from m-files, and as m-files compiled into the eml mex file, so they contain eml directives such as eml.target, eml.extrinsic, eml.varsize etc. It all works well from the matlab command line, but after I compile the project with mcc and try to run the executable, it fails with messages such as:
??? Undefined variable "eml" or class "eml.target".
Code for example - comp_test.m
function [ ] = comp_test( )
if isempty(eml.target)
disp('Regular');
else
disp('EML');
end
end
Compile with: mcc -m comp_test.m Then run: comp_test
or run_comp_test.sh <path to matlab installation >
and get the message: ??? Undefined variable "eml" or class "eml.target".
How do I solve this problem?

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 27 Sep 2011
The EML directives attempt to call into libraries that are not part of MATLAB Compiler Runtime, so you cannot execute this code in deployed mode. See Ineligible Programs for MATLAB Compiler - you will see that MATLAB Coder (the new product that corresponds to the EML directives) is one of them.
You could wrap your calls to EML directives with the isdeployed flag:
function [ ] = comp_test( )
if ~isdeployed && isempty(eml.target)
disp('Regular');
else
disp('EML');
end
end
  4 Comments
Kaustubha Govind
Kaustubha Govind on 3 Oct 2011
Hagay: It looks like isdeployed is supported for code-generation at least in the latest version of MATLAB: http://www.mathworks.com/help/releases/R2011a/toolbox/eml/ug/bq1h2z7-11.html
So upgrading could also be a solution.

Sign in to comment.

More Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!