Main Content

Custom Linking to Required API Libraries

MathWorks recommends that you use the mex command to build MEX files and engine applications. This build script automatically links to the libraries required by the MATLAB® APIs used in your application.

To custom build these applications using an Integrated Development Environment (IDE) instead of the mex command, refer to this list of required run-time libraries and include files. To identify path names, use these MATLAB commands.

  • Replace matlabroot with the value returned by matlabroot.

  • Replace compiler with either microsoft or mingw64.

  • The path to the include files is the value returned by:

    fullfile(matlabroot,'extern','include')

C++ MEX Functions

To build C++ MEX functions, use the C++ MEX API and MATLAB Data API.

Include files:

  • mex.hpp — Definitions for the C++ MEX API

  • mexAdapter.hpp — Utilities required by the C++ MEX function operator

Windows® libraries:

  • matlabroot\extern\lib\win64\compiler\libMatlabDataArray.lib

Linux® libraries:

  • Linux—matlabroot/extern/bin/glnxa64/libMatlabDataArray.so

macOS libraries:

  • macOSmatlabroot/extern/bin/maci64/libMatlabDataArray.dylib

C++ Engine Applications

To build C++ engine applications, use the MATLAB Engine API for C++ and MATLAB Data API.

Include files:

  • MatlabEngine.hpp — Definitions for the C++ engine API

  • MatlabDataArray.hpp — Definitions for MATLAB Data Arrays

Windows libraries:

  • Engine library — matlabroot\extern\lib\win64\compiler\libMatlabEngine.lib

  • MATLAB Data Array library — matlabroot\extern\lib\win64\compiler\libMatlabDataArray.lib

Linux libraries:

  • Engine library — matlabroot/extern/bin/glnxa64/libMatlabEngine.so

  • MATLAB Data Array library — matlabroot/extern/bin/glnxa64/libMatlabDataArray.so

macOS libraries:

  • Engine library — matlabroot/extern/bin/maci64/libMatlabEngine.dylib

  • MATLAB Data Array library — matlabroot/extern/bin/maci64/libMatlabDataArray.dylib

C MEX Functions

To build C MEX functions, use the C Matrix API and C MEX API functions listed in C MEX File Applications. Optionally, to read or write to MAT-files in your MEX functions, use the MATLAB C API to Read MAT-File Data.

Include files:

  • mex.h — Declares the entry point and interface routines

  • matrix.h — Definitions of the mxArray structure and function prototypes for matrix access routines

  • mat.h (optional) — Function prototypes for mat routines

Windows libraries:

  • matlabroot\extern\lib\win64\compiler\libmex.lib

  • matlabroot\extern\lib\win64\compiler\libmx.lib

  • matlabroot\extern\lib\win64\compiler\libmat.lib (optional)

Linux libraries:

  • matlabroot/bin/glnxa64/libmex.so

  • matlabroot/bin/glnxa64/libmx.so

  • matlabroot/bin/glnxa64/libmat.so (optional)

macOS libraries:

  • matlabroot/bin/maci64/libmex.dylib

  • matlabroot/bin/maci64/libmx.dylib

  • matlabroot/bin/maci64/libmat.dylib (optional)

C Engine Applications

To build C engine applications, use the C Matrix API and MATLAB Engine API for C. If you include C MEX API functions such as mexPrintf in you application, then you must link to the libmex library. For a list of functions, see C MEX File Applications. Optionally, to read or write MAT-files in your application, use the MATLAB C API to Read MAT-File Data.

Include files:

  • engine.h — Function prototypes for engine routines

  • matrix.h — Definition of the mxArray structure and function prototypes for matrix access routines

  • mat.h (optional) — Function prototypes for mat routines

Windows libraries:

  • Engine library — matlabroot\extern\lib\win64\compiler\libeng.lib

  • Matrix library — matlabroot\extern\lib\win64\compiler\libmx.lib

  • MEX library (optional) — matlabroot\extern\lib\win64\compiler\libmex.lib

  • MAT-File library (optional) — matlabroot\extern\lib\win64\compiler\libmat.lib

Linux libraries:

  • Engine library — matlabroot/bin/glnxa64/libeng.so

  • Matrix library — matlabroot/bin/glnxa64/libmx.so

  • MEX library (optional) — matlabroot/bin/glnxa64/libmex.so

  • MAT-File library (optional) — matlabroot/bin/glnxa64/libmat.so

macOS libraries:

  • Engine library — matlabroot/bin/maci64/libeng.dylib

  • Matrix library — matlabroot/bin/maci64/libmx.dylib

  • MEX library (optional) — matlabroot/bin/maci64/libmex.dylib

  • MAT-File library (optional) — matlabroot/bin/maci64/libmat.dylib

C MAT-File Applications

To build standalone applications to read data from C MAT-files, use the C Matrix API and MATLAB C API to Read MAT-File Data. If you include C MEX API functions such as mexPrintf in you application, then you must link to the libmex library. For a list of these functions, see C MEX File Applications.

Include files:

  • mat.h — Function prototypes for mat routines

  • matrix.h — Definitions of the mxArray structure and function prototypes for matrix access routines

Windows libraries:

  • MAT-File library — matlabroot\extern\lib\win64\compiler\libmat.lib

  • Matrix library — matlabroot\extern\lib\win64\compiler\libmx.lib

  • MEX library (optional) — matlabroot\extern\lib\win64\compiler\libmex.lib

Linux libraries:

  • MAT-File library — matlabroot/bin/glnxa64/libmat.so

  • Matrix library — matlabroot/bin/glnxa64/libmx.so

  • MEX library (optional) — matlabroot/extern/bin/glnxa64/libmex.so

macOS libraries:

  • MAT-File library — matlabroot/bin/maci64/libmat.dylib

  • Matrix library — matlabroot/bin/maci64/libmx.dylib

  • MEX library (optional) — matlabroot/extern/bin/maci64/libmex.dylib

See Also

Related Topics

External Websites