| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Files and Directories — UNIX 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. For more information, see Specifying a UNIX Options File.
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:
C/C++ header file for MATLAB engine programs. Contains function prototypes for engine routines.
C/C++ header file for programs accessing MAT-files. Contains function prototypes for mat routines.
C/C++ header file containing a definition of the mxArray structure and function prototypes for matrix access routines.
Header file for building C/C++ MEX-files. Contains function prototypes for mex routines.
Header file for building Fortran 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. For more information, see Specifying a Windows Options File.
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
C/C++ header file for MATLAB engine programs. Contains function prototypes for engine routines.
C/C++ header file for programs accessing MAT-files. Contains function prototypes for mat routines.
C/C++ header file containing a definition of the mxArray structure and function prototypes for matrix access routines.
Header file for building C/C++ MEX-files. Contains function prototypes for mex routines.
Header file for building Fortran MEX-files. Contains function prototypes for mex routines.
Files used by Microsoft Visual C++ and Microsoft Fortran compilers.
The matlabroot\extern\src directory contains files that are used for debugging MEX-files.
This book uses many examples to show how to write C and Fortran source MEX-files.
The refbook subdirectory in the extern/examples 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 standalone programs, most of these are MEX-file examples. The exception is mxSetAllocFcns.c, since this function is available only to standalone 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 standalone 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, updated several times each week, on our Web site includes thousands of solutions and links to Technical Notes.
http://www.mathworks.com/support/
Technical Notes
Our Technical Support staff writes technical notes to address commonly asked questions.
http://www.mathworks.com/support/tech-notes/list_all.html
[1] UNIX is a registered trademark of The Open Group in the United States and other countries.
![]() | Troubleshooting MEX-Files | Creating C Language MEX-Files | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |