Programmatic compilation of standalone windows app from Matlab project (similar to matlab.add​ons.toolbo​x.packageT​oolbox)?

5 views (last 30 days)
Hi, I finally managed to migrate my toolbox project to R2025a. As soon as everything works, the new Matlab version is really nice.
Here is my question: I have a Matlab project for my code. Under "Manage tasks", I made two tasks - one to generate a toolbox from my code, and another one to generate a standalone (windows) application from the same code. These two tasks work if I open them and then click on "package".
But ideally, I would like to do this programatically via the buildfile ("Run Build"). I can do it already for the toolbox using
matlab.addons.toolbox.ToolboxOptions("MyMatlabProjectFile.prj")
and
matlab.addons.toolbox.packageToolbox("MyMatlabProjectFile.prj")
But I would also like to do this for the standalone app. I do not find how to do this.
compiler.project.StandaloneAppConfigurationOptions
compiler.project.getStandaloneDesktopAppConfiguration
Although the above lines sound promising, these functions don't accept any inputs
And
compiler.build.standaloneWindowsApplication(AppFile)
does not accept a prj file as input.
Is there a way to compile a standalone app based on the task I created for my project? Thanks for your input!
  1 Comment
Gayathri
Gayathri on 5 Jun 2025
Please load the project in command line using the following command:
proj = matlab.project.loadProject('filename.prj');
Currently, we cannot directly pass the ".prj" file to the "compiler.build.standaloneApplication" function. Instead, please specify the main application file that serves as the entry point for your standalone application.
appFile = 'MyMainApp.m'; % Replace with your main app file name
% Create Standalone Application Options
opts = compiler.build.StandaloneApplicationOptions(appFile, ...
'OutputDir', 'C:\Path\To\Output\Directory', ... % Specify your output directory
'ExecutableName', 'MyStandaloneApp', ... % Name of the executable
'Verbose', 'On'); % Enable verbose output
% Build the standalone application
compiler.build.standaloneApplication(opts);
Let me know if this works and you get the expected results.

Sign in to comment.

Answers (0)

Categories

Find more on Standalone Applications in Help Center and File Exchange

Products


Release

R2025a

Community Treasure Hunt

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

Start Hunting!