Error in compiled application, constant property can't be found
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Simeon
el 28 de Ag. de 2025 a las 22:15
Comentada: Walter Roberson
el 29 de Ag. de 2025 a las 7:16
I compiled a standalone executable using the Application Compiler but get an error when starting it because of 'Unable to resolve the name TestHelperClass.TestString'. Matlab then throws this error: MATLAB:undefinedVarOrClass. The TestHelperClass looks like this:
classdef TestHelperClass
properties (Constant)
TestString = "test"
end
end
When using this way of getting predefined strings in MATLAB it works fine but not in compiled executables. Using get-functions which return the same strings results in the exact same error so sadly this doesn't work.
Is there a workaround for this error?
2 comentarios
dpb
el 28 de Ag. de 2025 a las 22:35
Did the compiler include the m-file containing the class definition in the required files?
Respuesta aceptada
Walter Roberson
el 29 de Ag. de 2025 a las 5:35
You need to create an object of class TestHelperClass and access the TestString property of that object.
Unfortunately it is not possible to subclass string class in order to hypthetically create an enumeration of type string.
2 comentarios
Walter Roberson
el 29 de Ag. de 2025 a las 7:16
file TestHelperClass.m
classdef TestHelperClass
properties (Constant)
TestString = "test";
end
methods
function obj = TestHelperClass()
end
end
end
together with separate
testHelpObj = TestHelperClass;
testHelpObj.TestString
However, you do not need the constructor in this particular case. It works to use file TestHelperClass.m
classdef TestHelperClass
properties (Constant)
TestString = "test";
end
end
The seperate assignment to testHelpObj must not be part of TestHelperClass.m
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Compiler en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!