How to build a standalone application programmatically in R2019a?

조회 수: 18 (최근 30일)
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
J. Alex Lee
J. Alex Lee 2021년 8월 11일
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 2021년 8월 11일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2021년 8월 11일
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
Jason Brasseur
Jason Brasseur 2023년 4월 20일
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 2023년 4월 20일
편집: Image Analyst 2023년 4월 20일
@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);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Standalone Applications에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by