Interesting, I assume you are trying to compile a function that can dynamically compile other functions..
Unfortunately, I dont think the mcc
function can be compiled/deployed itself
To be exact, the problem you are seeing is because MATLAB needs to know all functions called at compile-time, and by using eval
, it wont figure it out on its own (since it wont parse inside the string). You can fix this particular issue by writing special comments for the compiler..
function myEval()
%#function foo
eval('...');
end
(Another alternative is using function handles).
Still even if you do that, it will fail at runtime inside the mcc
function saying that: "License checkout failed, [...] Cannot find a valid license for Compiler"
.
The reason is as mentioned in the comments, mcc
is a development tool and cannot be deployed to standalone programs which only depends on the free MCR runtime.
Think about it, if it was possible, it would defeat the whole purpose of buying licenses for the product, as you could create a standalone program that can compiler other codes without having the Compiler toolbox :)