Home > Net >  How to add files required for your application to run in MATLAB
How to add files required for your application to run in MATLAB

Time:06-03

I want to automate the compiling of my MATLAB script to an installer with MATLAB's compiler.build.standaloneApplication to create the standalone app and compiler.package.installer to create an installer.

I have python_script.exe file that my MATLAB script uses that is why I want to add it during creating the standalone app. The issue is the installed application using the outputted installer with the code below isn't adding the necessary python.exe file.

Here is my current progress.

Create the standalone app code.

opts = compiler.build.StandaloneApplicationOptions(...
        'main.m', ...
        'EmbedArchive', 'On', ...
        'ExecutableIcon', 'C:\Program Files\MATLAB\.\toolbox\compiler\resources\default_icon_48.png', ...
        'ExecutableName', 'test_app', ...
        'ExecutableSplashScreen', 'C:\Program Files\MATLAB\.\toolbox\compiler\resources\default_splash.png', ...
        'ExecutableVersion', '1', ...
        'TreatInputsAsNumeric', 'Off', ...
        'AdditionalFiles', ['python_script.exe'], ...
        'AutoDetectDataFiles', 'off', ...
        'OutputDir', '.\test_app_installer' ...
    );
results = compiler.build.standaloneApplication(opts);

Use the result to create the package installer using the code below.

compiler.package.installer(results)

CodePudding user response:

The 'AdditionalFiles' option should be a [cell array of file names] (https://www.mathworks.com/help/compiler/compiler.build.standaloneapplication.html#mw_a47875f5-3a84-410b-9b4c-553a4c1d621e).

Change

['python_script.exe']

to

{'python_script.exe'}

Also make sure that the file python_script.exe is on the Matlab path on in the directory where the build is started.

  • Related