Matlab Compiler fails to include enum class with no methods

7 ビュー (過去 30 日間)
Eric Hardin
Eric Hardin 2020 年 1 月 6 日
編集済み: Eric Hardin 2020 年 1 月 7 日
I'm trying to compile matlab 2017a code. When I run the compiled code I get the following runtime error:
Standard exception: *.cpp:line# -- Undefined variable "EnumClass" or class "EnumClass.enum1".
The enum class is defined according to https://www.mathworks.com/help/matlab/matlab_oop/enumerations.html. Roughly:
classdef EnumClass
enumeration
enum1, enum2, enum3
end
end
I suspect this is because the Matlab Compiler fails to detect EnumClass as a dependency because the matlab compiler detects dependencies using only functions https://www.mathworks.com/matlabcentral/answers/323654-compiler-and-missing-source-files. The enum class has no functions to call.
I know that I can manually specify dependencies with the mcc -a flag, but this is not very maintainable for my situation. There are multiple separate teams each working on modules that get compiled in a programmatic way. So manually specifying dependencies creates undesirable complexity in this process.
Is there a way to change EnumClass or its caller to cue the Matlab Compiler that EnumClass is a dependency?

回答 (1 件)

Kojiro Saito
Kojiro Saito 2020 年 1 月 7 日
Enumeration class can be also included in a standalone application by MATLAB Compiler without specifying the dependency. I have confirmed in R2019b Update 3 that the following command creates a standalone application properly.
mcc -m callEnumTest.m
callEnumTest.m
function callEnumTest
thisDay = WeekDays.Tuesday;
disp(thisDay)
end
WeekDays.m
classdef WeekDays
enumeration
Monday, Tuesday, Wednesday, Thursday, Friday
end
end
I also confimed that Application Compiler app can add dependent files (WeekDays.m) properly.
Anyway, you can add dependencies manually by adding "-a" option in mcc command. For example,
mcc -m callEnumTest.m -a WeekDays.m
  1 件のコメント
Eric Hardin
Eric Hardin 2020 年 1 月 7 日
Thank you for your prompt response. I think I failed to mention some details. I have updated my question. Any additional information would be greatly appreciated.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by