I have a piece of MATLAB code that I'm trying to compile into a standalone. The uncompiled version works fine, but when I compile it and run from a DOS command window, I encounter an error
Unknown class 'SeparableLinearOp' used in builtin function 'SUPERIORTO'
The call to superiorto is in the constructor of a second, old-style class. The class SeparableLinearOp is not being used, so I didn't provide code for it. Because SeparableLinearOp is not being used, the M-code version doesn't care about its absence. Why does the compiled version care?
After working with tech support, the problem seems to be resolved. Basically, if you call superiorto('ClassA','ClassB',...,'ClassZ'), then definitions for all those classes have to be in the CTF archive. However, as usual, the compilation process isn't always smart enough to know what to include in the archive and you have to force the inclusion of certain things with pragmas. This was the case for SeparableLinearOp, because it was never actually invoked. It just appeared within the list of string arguments to SUPERIORTO.
However, a more convenient solution than adding pragmas was to dynamically detect which classes were present and adjust the superiorto argument list accordingly:
oldclasses=cellfun(@(c) exist(['@' c],'dir'), inferiorClasses ); newclasses=cellfun(@(c) exist(c,'file'), inferiorClasses );
It's a bit of a shame, of course, that SUPERIORTO can't just ignore undefined classes. It also would have saved some headache if exist(...,'class') worked on old style classes as well as new ones.
Are you sure it's not being used. Run this:
and really check for it. It might be buried in there unbeknownst to you through a call to a function you don't suspect is using it. Generally you can' compile in modules that have extensive user interfaces with them - for example imtool. When you compile, the excluded log will list files that cannot be included in the compiled versions.
Play games and win prizes!Learn more