How do I compile and run a MATLAB Engine program on UNIX/Linux/Mac?

22 views (last 30 days)
I have completed the steps in the External Interfaces manual but I am having difficulty compiling and running my Engine program. I would like step-by-step instructions on how to achieve this.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Oct 2013
This enhancement has been incorporated in Release 2006b (R2006b). For previous product releases, read below for any possible workarounds:
To run an Engine application, you must set the path and the dynamic library path on your machine appropriately.
Perform the following steps:
1. To add MATLAB to the path environment variable:
On a bash shell, enter
export PATH=$PATH:(<matlabroot>/bin)
On a csh / tcsh shell, enter
set path = ($path <matlabroot>/bin)
where <matlabroot> is the path where MATLAB is installed and can found by entering
matlabroot
at the MATLAB Command Prompt.
2. On MATLAB 6.5(R13) Set the runtime library path environment variable LD_LIBRARY_PATH to:
<matlabroot>/extern/lib/<arch>:<matlabroot>/sys/os/<arch>:$LD_LIBRARY_PATH
On MATLAB 7.0(R14) and later set the runtime library path environment variable LD_LIBRARY_PATH to:
<matlabroot>/bin/<arch>:<matlabroot>/sys/os/<arch>:$LD_LIBRARY_PATH
Where <matlabroot> is the path to your MATLAB installation, and <arch> is the proper architecture/OS directory such as glnx86 if you are using x86 Linux.
Some UNIX operating systems use SHLIB_PATH or DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH, and therefore you may need to set them instead of LD_LIBRARY_PATH. For more details, and to see which one you should set, see the following URL:
3. Start MATLAB.
4. Compile and link the engdemo.c example:
mex -f <matlabroot>/bin/engopts.sh <pathname>/engdemo.c
where <pathname> specifies the complete path to the specified file.
5. Exit MATLAB.
6. From your shell prompt, execute:
<pathname>/engdemo

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!