How to build a standalone application programmatically in R2019a?

10 Ansichten (letzte 30 Tage)
In the current MATLAB Compiler documentation there is a section on how to "Create Standalone Application Using Application Compiler App" that includes instructions on how to do this programmatically (e.g., "Create Standalone Application Using Application Compiler App"). Similar instructions do not exist in the R2019a documentation and I can't find any documentation on an alternative. Is it possible to build a standalone application programmatically in R2019a, or am I relegated to using the GUI only?
  2 Kommentare
J. Alex Lee
J. Alex Lee am 11 Aug. 2021
i just clicked on your 2019a doc link and saw that page 1-6 has the section titled "Create Standalone Application Using Application Compiler App"
Monika Jaskolka
Monika Jaskolka am 11 Aug. 2021
There is the section "Create Standalone Application Using Application Compiler App", but it lacks any instructions on how to do it programmatically. It only contains GUI-based instructions.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 11 Aug. 2021
I never use the GUI app, deploytool, to compile me apps. I always have a script where I call mcc programmatically because I want to do things, like ask the user (myself) if they've updated the version number, perhaps ask which m-files to compile (if there is a whole suite of them), time how long the compilation takes, and things like that. I have a script called compile.m and in there I call mcc to do the compilation programmatically, along with other things.
  3 Kommentare
Jason Brasseur
Jason Brasseur am 20 Apr. 2023
Hello Image Analyst - I'm curious if you'd be willing to share your compile.m script referenced above - compiling exe's programatically is of interest to me and being able to see another person's routine would be a helpful starting point.
Thank you and best regards!
Image Analyst
Image Analyst am 20 Apr. 2023
Bearbeitet: Image Analyst am 20 Apr. 2023
@Jason Brasseur here is an example of one. Sort of a general purpose one for me. I change the suite name and individual m-file names depending on the project it's being used with.
echo off;
clc;
format compact;
% Change this next line, and then the next line. The rest might not need much change.
suiteFolderName = 'Jason Project';
% List all the files to compile. Make sure they all end with .m.
mFilesToCompile = {'myapp.m', 'trainSegNet.m', 'predictMask.m', 'RenameImages.m'};
% Define the top level folders for the source code and the output executables.
workFolder = 'C:\Users\Jason\OneDrive\Matlab\work\';
outputTopFolder = 'C:\Users\Jason\OneDrive\Matlab\Compiled\';
% Create a file that says what MATLAB release we need to run the compiled application(s).
MakeRequiredMATLABReleaseFile;
% Disable startup.m from being included in compiled programs. Does this by renaming 'startup.m' to 'startup (Disabled).m'.
% I'm doing this to avoid the warning about having cd in the startup.m file when it compiles.
EnableStartupDotM(false);
tic
% Change directory to the source code folder.
sourceCodeFolder = fullfile(workFolder, suiteFolderName);
if ~isfolder(sourceCodeFolder)
message = sprintf('Folder %s does not exist!', sourceCodeFolder);
WarnUser(message);
return; % Can't find source code so we can't do anything.
end
cd(sourceCodeFolder);
promptMessage = sprintf('Have you updated the Version Number file already?');
button = questdlg(promptMessage, 'Yes - Continue', 'Yes - Continue', 'No - Cancel', 'Yes - Continue');
if strcmp(button, 'No - Cancel')
edit 'Version Number.txt';
return;
end
% Specify the output folder, creating it if needed, where the executable will be placed after it's created.
outputFolder = fullfile(outputTopFolder, suiteFolderName);
if ~isfolder(outputFolder)
mkdir(outputFolder);
end
rehash toolboxcache;
fprintf('Toolbox cache has been successfully rehashed.\n');
% Loop over all filenames
numMFiles = length(mFilesToCompile);
for k = 1 : numMFiles
mFileName = mFilesToCompile{k};
if ~isfile(mFileName)
promptMessage = sprintf('%s m-file not found.\nDo you want to Continue compiling the other files,\nor Quit?', mFileName);
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit', 'IgnoreCase', true)
return;
end
fprintf('Skipping compile of %s m-file because it was not found.\n', mFileName);
else
fprintf('Beginning compile of %s application (#%d of %d) at %s ...\n', mFileName, k, numMFiles, datestr(now, 'HH:MM:SS AM'));
mcc('-m', mFileName, '-d', outputFolder);
end
end
% echo off;
% disp([repmat(char(8), 1, 11)]); % Get rid of "echo off" from command window.
fprintf('Finished compile of %s application at %s.\n', suiteFolderName, datestr(now, 'HH:MM:SS AM'));
elapsedSeconds = toc;
minutes = int32(floor(elapsedSeconds / 60));
seconds = elapsedSeconds - 60 * double(minutes);
message = sprintf('\nIt is done compiling %d m-files in %s.\nIt took %d minutes and %.1f seconds.\n', numMFiles, suiteFolderName, minutes, seconds);
% Reenable startup.m. Does this by renaming 'startup (Disabled).m' to 'startup.m'.
EnableStartupDotM(true);
fprintf('%s\n', message);
PlaySoundFile('D:\WaveFiles\Effects', 'DingLing.wav');
msgbox(message);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Standalone Applications finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by