Main Content

Build and Run C Engine Application on Windows

Note

The MATLAB® Engine API for C++ is recommended over the Engine API for C. The MATLAB Engine API for C++ includes modern C++ features for writing engine applications. For more information, see Call MATLAB from C++. There are no plans to remove the Engine API for C.

This example shows how to verify the build process on Windows® platforms using this C code.

 engwindemo.c

Make note of the value of matlabroot (the folder where MATLAB is installed) .

Start MATLAB and register MATLAB as a COM server. For more information, see Register MATLAB as COM Server.

comserver("register")

MATLAB displays a second, minimized command window. Close that window.

Verify your current folder is writable and copy the example.

copyfile(fullfile(matlabroot,"extern","examples","eng_mat","engwindemo.c"),".","f")

Choose a compiler, if necessary.

mex -setup -client engine C

Build the application.

mex -v -client engine engwindemo.c

Set the run-time library path by modifying the system PATH variable.

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

Make sure that you include the ; path terminator character.

Run the example. The engwindemo application must be on your system path.

engwindemo

MATLAB starts and displays the results.

To close the application, click Ok in the MATLAB whos window.

See Also

|

Topics