Main Content

How To Run a Generated Executable Outside MATLAB

You can generate a standalone executable from the System objects and blocks in DSP System Toolbox™ which support code generation. This executable can run outside the MATLAB® and Simulink® environments.

To generate an executable from the System objects, you must have the MATLAB Coder™ installed. To generate an executable from the Simulink blocks, you must have the Simulink Coder installed in addition to the MATLAB Coder.

The executables generated from the following objects and blocks rely on prebuilt dynamic library files (.dll files) included with MATLAB.

System Objects

Objects

  • dsp.ISTFT (when the FFT length determined by the number of input rows is not a power of 2)

Blocks

  • Audio Device Writer

  • Burg Method (when the FFT length is not a power of two)

  • From Multimedia File

  • To Multimedia File

  • FFT

    • When FFT implementation is set to FFTW.

    • When you clear the Inherit FFT length from input dimensions check box, and set FFT length to a value that is not a power of two.

  • IFFT

    • When FFT implementation is set to FFTW.

    • When you clear the Inherit FFT length from input dimensions check box, and set FFT length to a value that is not a power of two.

  • Inverse Short-Time FFT (when the input length is not a power of two)

  • Magnitude FFT

    • When FFT implementation is set to FFTW.

    • When you clear the Inherit FFT length from input dimensions check box, and set FFT length to a value that is not a power of two.

  • Periodogram

    • When FFT implementation is set to FFTW.

    • When you clear the Inherit FFT length from input dimensions check box, and set FFT length to a value that is not a power of two.

  • Short-Time FFT (when the FFT length is not a power of two)

  • UDP Receive

  • UDP Send

Running the Executable

To run the corresponding executable outside the MATLAB and Simulink environments, for example Windows® command prompt on a Windows machine, you must include these prebuilt .dll files. The method of including the .dll files depends on whether MATLAB or MATLAB compiler runtime (MCR) is installed on the external machine. The MATLAB compiler runtime (MCR), also known as MATLAB Runtime, is a standalone set of shared libraries, MATLAB code, and other files that enables the execution of MATLAB files on computers without an installed version of MATLAB. For more details on MCR, see About MATLAB Runtime (MATLAB Compiler).

MATLAB or MCR is not installed on the machine you are running the executable

To run the executable generated from the above System objects and blocks on a machine that does not have MATLAB or MCR installed, use the packNGo function. The packNGo function packages all the relevant files including the prebuilt .dll files in a compressed zip file so that you can relocate, unpack, and rebuild your project in another development environment where MATLAB or MCR is not installed.

You can use the packNGo function at the command line or the Package option in the MATLAB Coder app. The files are packaged in a compressed file that you can relocate and unpack using a standard zip utility. For more details on how to pack the code generated from MATLAB code, see Relocate Code Generated from MATLAB Code to Another Development Environment. For more details on how to pack the code generated from Simulink blocks, see Relocate Code Generated from a Simulink Model to Another Development Environment.

MATLAB or MCR is installed on the machine you are running the executable

To include the prebuilt .dll files on a machine with MATLAB or MCR installed, set your system environment by running the commands below. These commands assume that the computer has MATLAB installed. If you run the standalone executable on a machine with only MCR, and no MATLAB installed, replace $MATLABROOT/bin/.... with the path to the MCR.

PlatformCommand
Mac

setenv DYLD_LIBRARY_PATH "${DYLD_LIBRARY_PATH}:$MATLABROOT/bin/maca64" (csh/tcsh on Apple silicon)

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MATLABROOT/bin/maca64 (Bash on Apple silicon)

setenv DYLD_LIBRARY_PATH "${DYLD_LIBRARY_PATH}:$MATLABROOT/bin/maci64" (csh/tcsh on Mac Intel®)

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MATLABROOT/bin/maci64 (Bash on Mac Intel)

For more information, see Append library path to "DYLD_LIBRARY_PATH" in MAC.

Linux

setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$MATLABROOT/bin/glnxa64 (csh/tcsh)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MATLABROOT/bin/glnxa64 (Bash)

Windows

set PATH=%PATH%;%MATLABROOT%\bin\win64

Related Topics