Third Party Add-On Seeming to Not Compile with App Designer's Application Compiler
    5 views (last 30 days)
  
       Show older comments
    
MATLAB Version R2021a
I am programming an app in App Designer that uses this third-party Add-On from the Zaber software suite. Its purpose is to control a Zaber stage.
When I use the code in App Designer, I am able to control the stage both in the App Designer environment and through the Matlab command line with the appropriate commands. All "import" functions work and communication through serial ports, stage control, etc., all work without any troubles. However, when I package and then try to run my app independent of Matlab's environment, I receive an error that implies the compiled code is not parsing or processing the Add-On or the Zaber library correctly.
Code error: "Unable to find or import 'zaber.motion.ascii.Connection'. Imported names must end with '.*' or be fully qualified."
When I export/package my app, I am using "Share -> Standalone Desktop App" primarily. I only test with the code shown below in an attempt to get around my error.
>> mcc('-m','myapp.mlapp','-a','Zaber Motion Library.mltbx');
However, when using the above code, I get the exact same error when running the executable.
Here are some solutions I have tried:
- Renaming 'import zaber.motion....' to 'import zaber.motion.*' everywhere in the code. However, this produces a "Dot indexing is not supported for variables of this type" error referencing a connection.close() call in a try-catch loop, likely as a result of the code not being able to access the Zaber motion library to send the openSerialPort command.
- Including the Motion Library in the "Files Required for your Program to Run" section, which gives the import error
- Using matlab.addons.install() function before calling any import functions, which gives the import error
Here is an example code block using the Zaber motion library add-on:
function [connection,axis] = buildapp(app)
    global connection axis
    import zaber.motion.*; %use this alone
%             import zaber.motion.ascii.Connection; %use these together
%             import zaber.motion.Units; %use these together
    try
        connection = Connection.openSerialPort('COM4');
        deviceList = connection.detectDevices();
        device = deviceList(1);
        axis = device.getAxis(1);
    catch exception
        uialert(app.UIFigure,'Connection error! Most likely that serial port is already open. Restart program.',...
            'Connection Failure!');
        connection.close();
        return;
    end
end
2 Comments
  Sumukh
 on 4 Nov 2024
				Can you please share the code and application here so as to try to reproduce and resolve the issue?
Answers (0)
See Also
Categories
				Find more on MATLAB Compiler in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
