2

I have Matlab script that I am trying to compile as an executable that will run on a headless server as part of a large batch process. The script calls functions and classes written by several non-programmers (scientists) over the span of more than a decade, and I am having a difficult time getting it to compile.

The script will run in a Matlab instance, but MCC gives me an error that I do not quite understand:

Compiler version: 5.1 (R2014a)
Dependency analysis by REQUIREMENTS.
Error using matlab.depfun.internal.MatlabSymbol/proxy (line 405)
Internal1 Error: Could not determine class of method
"/home/me/MyCode/@tsd/Data.m". Number of classes checked:
17.

@tsd/tsd.m looks like this:

function tsa = tsd(t, Data)

% tsd  Creates tsd object (tsd = class of timestamped arrays of data)
%
% tsa = tsd(t, Data)
%
% INPUTS: 
%       t - list of timestamps - must be sequential, but don't have to be continuous
%       Data - data, possibly an array. If data is n-dimensional, then time should be the FIRST axis.
% OUTPUTS: 
%       tsa - a tsd object
%
% Completely compatible with ctsd.
%
% Methods
%    tsd/Range     - Timestamps used
%    tsd/Data      - Returns the data component
%    tsd/DT        - Returns the DT value (mean diff(timestamps))
%    tsd/StartTime - First timestamp
%    tsd/EndTime   - Last timestamp
%    tsd/Restrict  - Keep data within a certain range
%    tsd/CheckTS   - Makes sure that a set of tsd & ctsd objects have identical start and end times
%    tsd/cat       - Concatenate ctsd and tsd objects
%    tsd/Mask      - Make all non-mask values NaN
%
% ADR 1998, version L4.0, last modified '98 by ADR

% RELEASED as part of MClust 2.0
% See standard disclaimer in ../Contents.m


if nargin == 0
 tsa.t = NaN;
 tsa.data = NaN;
 tsa = class(tsa, 'tsd');
 return
end 

if nargin < 2
  error('tsd constructor must be called with T, Data');
end

tsa.t = t;
tsa.data = Data;

tsa = class(tsa, 'tsd');

and the Data.m file:

function v = Data(tsa, ix)

% tsd/Data  Retrieves data from tsd
%
%   d = Data(tsa)
%   d = Data(tsa, ix)
%
% INPUTS:
%       tsa - tsd object
%       ix - alignment list (timestamps)
% OUTPUTS:
%       v - the tsa.Data
%
%   if called with alignment list, returns those tsa.Data(ix)
%   if called without, returns complete tsa.Data
%
% ADR 1998, version L4.1, last modified '98 by ADR

% RELEASED as part of MClust 2.0
% See standard disclaimer in ../Contents.m


switch nargin
case 2
   f = findAlignment(tsa, ix);
   v = SelectAlongFirstDimension(tsa.data,f);
case 1
   v = tsa.data;
otherwise
   error('Unknown number of input arguments');
end

So the script calling the tsd function runs just find in the Matlab session, but the compiler throws the error described above. This is my first time working with Matlab and I am totally stumped. There is another class with a method named "Data", but that shouldn't cause this problem, could it?

nick topper
  • 105
  • 7
  • You say you're trying to compile a script, you mean the wtf thing that generally starts with `clear all; close all; clc` instead of `function [...] = foo(...)` ? ... If so, the compiler does not support working with scripts, you have to turn all of them into functions. NB: Not sure this can be the issue because i guess mcc would have return more appropriate error message in this case. – CitizenInsane Jul 04 '14 at 05:58
  • @nick topper just to let you know I'm having the same issue under Linux and not under Windows. Which platform are you using? – Nicholas Jul 07 '14 at 08:57

1 Answers1

0

I was having the exact same problem and was able to come up with a workaround.

I was facing this problem when I was compiling the MATLAB library using the command

mcc -W cpplib:LibName -T link:lib main.m -a './' -d 'dll_destintaion_dir'

LibName: DLL name
main.m: MATLAB entry point
dll_destintaion_dir: destination where DLL created will be stored

The error was gone when I compiled using this command instead

mcc -W cpplib:LibName -T link:lib main.m -a 'full_path_of_project_folder/*' 
-d 'dll_destintaion_dir'

Note: This method does not add folders recursively to the archive. So subfolders have to be added explicitly using another -a flag in the command shown above.

Vishy
  • 79
  • 1
  • 4