Main Content

Build and Run Fortran Engine Applications on macOS

This example shows how to build and run the example fengdemo.F from the macOS Terminal Window.

Open MATLAB®.

Make note of the value of matlabroot (the folder where MATLAB is installed) command. You will use the value later to set the run-time library path.

matlabroot

Verify your current folder is writable and copy the example.

copyfile(fullfile(matlabroot,'extern','examples','eng_mat','fengdemo.F'),'.','f')

Build the application.

mex -v -client engine fengdemo.F

Set the system path. Make sure that you include the : path terminator character.

setenv PATH matlabroot/bin:$PATH

Set the run-time library path and call the fengdemo application. The application must be on your system path. This command replaces the value, if any, in DYLD_LIBRARY_PATH. Replace macos with either maca64 for macOS with Apple silicon or maci64 for macOS with Intel®. For more information, see Set Run-Time Library Path on macOS Systems.

DYLD_LIBRARY_PATH=matlabroot/bin/macos:matlabroot/sys/os/macos ./fengdemo

MATLAB starts and displays a figure.

Type 1 <Enter> at the system prompt to continue and exit.

Related Examples

More About