2

我有 Matlab 脚本,我正在尝试将其编译为可执行文件,该脚本将作为大型批处理过程的一部分在无头服务器上运行。该脚本调用了几位非程序员(科学家)在十多年的时间里编写的函数和类,我很难编译它。

该脚本将在 Matlab 实例中运行,但 MCC 给了我一个我不太明白的错误:

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 看起来像这样:

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');

和 Data.m 文件:

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

所以调用 tsd 函数的脚本只在 Matlab 会话中运行 find ,但是编译器会抛出上述错误。这是我第一次使用 Matlab,我完全被难住了。还有另一个类有一个名为“Data”的方法,但这不应该导致这个问题,不是吗?

4

1 回答 1

0

我遇到了完全相同的问题,并且能够想出一个解决方法。

我在使用命令编译 MATLAB 库时遇到了这个问题

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

LibName:DLL 名称
main.m:MATLAB 入口点
dll_destintaion_dir:将存储创建的 DLL 的目的地

当我使用此命令编译时,错误消失了

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

注意:此方法不会递归地将文件夹添加到存档中。因此,必须在上面显示的命令中使用另一个 -a 标志显式添加子文件夹。

于 2014-07-28T14:33:00.983 回答