Build and Run Fortran Engine Applications on Windows
This example shows how to build and run the Fortran example
fengdemo.F
on Windows® platforms.
Start MATLAB® as a user with administrator privileges. Based on your User Account Control (UAC) settings, you might need to right-click the MATLAB icon and select Run as administrator. If that option is not available, contact your system administrator.
Register MATLAB as a COM server.
!matlab -regserver
MATLAB displays a second, minimized command window. Close that window.
Make note of the value of matlabroot
(the folder where
MATLAB is installed) and the value returned by the MATLAB
computer('arch')
command. You will use the value res
later to set the run-time library path in a set PATH
command.
res = fullfile(matlabroot,'bin',computer('arch'))
Verify that your current folder is writable and copy the example.
copyfile(fullfile(matlabroot,'extern','examples','eng_mat','fengdemo.F'),'.','f')
Choose a compiler, if necessary.
mex -setup -client engine Fortran
Build the application.
mex -v -client engine fengdemo.F
Open a Windows command prompt.
Set the run-time library path by modifying the system PATH
variable. Use the value res
from the previous step. Make sure that you
include the ;
path terminator character.
set PATH=matlabroot\bin\arch;%PATH%
Run the example. The fengdemo
application must be on your system
path.
fengdemo
MATLAB starts and displays a figure.
Type 1 <Enter>
at the system prompt to continue and exit.
Alternatively, you can use an integrated development environment (IDE) such as Microsoft® Visual Studio® or Xcode to build your application. For more information, see Build Engine Applications with IDE.
See Also
mex
| computer
| matlabroot