MATLAB Answers

Matt J

MATLAB compiler and superiorto

Asked by Matt J
on 10 Oct 2012
Accepted Answer by Matt J

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?


2 Answers

Answer by Matt J
on 16 Oct 2012
 Accepted answer

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.


Answer by Image Analyst
on 10 Oct 2012

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.


I agree with point 2. If it's one of the Mathworks routines, it should have been there. If it's someone else's it won't be there and you have to ship it separately or have deploytool include it as an extra shippable file. fdep is a lot more comprehensive that the dependency report. Looks like tech support may be your final option. Come back here and report what finally fixes it, or add it to the FAQ's compile problems section.

Matt J
on 11 Oct 2012

You agree with point (2) but not the first bullet point of part (1)? Why would the compiled version need it if the uncompiled version does not?

I didn't disagree with point 1, I just didn't have any comment on it. I have no explanation for what you're seeing. As you know, it makes little sense.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!