| MATLAB® | ![]() |
| On this page… |
|---|
Files and Directories — UNIX® Operating Systems Files and Directories — Microsoft® Windows® Operating Systems |
This section describes the directory organization and purpose of the files associated with the MATLAB® C and Fortran API on UNIX®[1] systems.

The matlabroot/bin directory contains two files that are relevant for the MATLAB API:
UNIX shell script that creates binary MEX-files from C or Fortran MEX-file source code.
UNIX shell script that initializes your environment and then invokes the MATLAB interpreter.
This directory also contains the preconfigured options files that the mex script uses with particular compilers. See Preconfigured Options Files for more information.
The matlabroot/bin/$ARCH directory contains libraries, where $ARCH specifies a particular UNIX platform. On some UNIX platforms, this directory contains two versions of this library. Library file names ending with .so or .dylib are shared libraries.
The matlabroot/extern/include directory contains the header files for developing C and C++ applications that interface with MATLAB.
The relevant header files for the MATLAB API are:
Header file for MATLAB engine programs. Contains function prototypes for engine routines.
Header file for programs accessing MAT-files. Contains function prototypes for mat routines.
Header file containing a definition of the mxArray structure and function prototypes for matrix access routines.
Header file for building MEX-files. Contains function prototypes for mex routines.
The matlabroot/extern/src directory contains those C source files that are necessary to support certain MEX-file features such as argument checking and versioning.
This section describes the directory organization and purpose of the files associated with the MATLAB C and Fortran API on Microsoft® Windows® systems.
The following figure illustrates the directories in which the MATLAB API files are located. In the illustration, matlabroot symbolizes the top-level directory where MATLAB is installed on your system.

The matlabroot\bin directory contains the mex.bat batch file that builds C and Fortran files into binary MEX-files. Also, this directory contains mex.pl, which is a Perl script used by mex.bat.
The matlabroot\bin\win32\mexopts or matlabroot\bin\win64\mexopts directory contains the preconfigured options files that the mex script uses with particular compilers. See Preconfigured Options Files for more information.
The matlabroot\extern\include directory contains the header files for developing C and C++ applications that interface with MATLAB.
The relevant header files for the MATLAB API (MEX-files, engine, and MAT-files) are
Header file for MATLAB engine programs. Contains function prototypes for engine routines.
Header file for programs accessing MAT-files. Contains function prototypes for mat routines.
Header file containing a definition of the mxArray structure and function prototypes for matrix access routines.
Header file for building MEX-files. Contains function prototypes for mex routines.
Files used by Microsoft® Visual C++® and Microsoft Fortran compilers.
Resource file for inserting versioning information into MEX-files.
The matlabroot\extern\src directory contains files that are used for debugging MEX-files.
directory contains the MEX-file examples (C and Fortran) that are used in this topic.
The mex subdirectory of /extern/examples directory contains MEX-file examples. It includes the examples described in the online MATLAB C and Fortran API Reference for MEX-Files (the functions beginning with the mex prefix).
The mx subdirectory of extern/examples contains examples for using the array access functions. Although you can use these functions in stand-alone programs, most of these are MEX-file examples. The exception is mxSetAllocFcns.c, since this function is available only to stand-alone programs.
The eng_mat subdirectory in the extern/examples directory contains the MEX-file examples (C and Fortran) for using the MATLAB engine facility, as well as examples for reading and writing MATLAB data files (MAT-files). These examples are all stand-alone programs.
The MathWorks provides additional Technical Support through its Web site. A few of the services provided are as follows:
Solution Search Engine
This knowledge base on our Web site includes thousands of solutions and links to Technical Notes and is updated several times each week.
http://www.mathworks.com/support/
Technical Notes
Technical notes are written by our Technical Support staff to address commonly asked questions.
http://www.mathworks.com/support/tech-notes/list_all.shtml
[1] UNIX is a registered trademark of The Open Group in the United States and other countries.
![]() | Troubleshooting | Creating C Language MEX-Files | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |