Custom Linking to Required API Libraries - MATLAB & Simulink (original) (raw)
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 bymatlabroot. - Replace
compiler
with eithermicrosoft
ormingw64
. - Replace
macos
with eithermaca64
for macOS with Apple silicon ormaci64
for macOS with Intel®. - 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 for C++.
Include files:
mex.hpp
— Definitions for the C++ MEX APImexAdapter.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:
- macOS—
_`matlabroot`_/extern/bin/_`macos`_/libMatlabDataArray.dylib
C++ Engine Applications
To build C++ engine applications, use the Call MATLAB from C++ andMATLAB Data API for C++.
Include files:
MatlabEngine.hpp
— Definitions for the MATLAB Engine API for C++MatlabDataArray.hpp
— Definitions for a generic interface between C++ and MATLAB data
Windows libraries:
- Engine library —
_`matlabroot`_\extern\lib\win64\_`compiler`_\libMatlabEngine.lib
- MATLAB Data library —
_`matlabroot`_\extern\lib\win64\_`compiler`_\libMatlabDataArray.lib
Linux libraries:
- Engine library —
_`matlabroot`_/extern/bin/glnxa64/libMatlabEngine.so
- MATLAB Data library —
_`matlabroot`_/extern/bin/glnxa64/libMatlabDataArray.so
macOS libraries:
- Engine library —
_`matlabroot`_/extern/bin/_`macos`_/libMatlabEngine.dylib
- MATLAB Data library —
_`matlabroot`_/extern/bin/_`macos`_/libMatlabDataArray.dylib
C MEX Functions
To build C MEX functions, use the C Matrix API and C MEX API functions listed in Write C Functions Callable from MATLAB (MEX Files). Optionally, to read or write to MAT-files in your MEX functions, use the Write C Programs to Read MAT File Data.
Include files:
mex.h
— Declares the entry point and interface routinesmatrix.h
— Definitions of themxArray
structure and function prototypes for matrix access routinesmat.h
(optional) — Function prototypes format
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/_`macos`_/libmex.dylib
_`matlabroot`_/bin/_`macos`_/libmx.dylib
_`matlabroot`_/bin/_`macos`_/libmat.dylib
(optional)
Fortran MEX Functions
To build Fortran MEX functions, use the Fortran Matrix API and Fortran MEX API functions listed inWrite Fortran Functions Callable from MATLAB (MEX Files). Optionally, to read or write to MAT-files in your MEX functions, use the Write Fortran Programs to Read MAT File Data.
Include files:
mex.h
— Declares the entry point and interface routinesmatrix.h
— Definitions of themxArray
structure and function prototypes for matrix access routinesmat.h
(optional) — Function prototypes format
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/_`macos`_/libmex.dylib
_`matlabroot`_/bin/_`macos`_/libmx.dylib
_`matlabroot`_/bin/_`macos`_/libmat.dylib
(optional)
C Engine Applications
To build C engine applications, use the C Matrix API and Call MATLAB from 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 Write C Functions Callable from MATLAB (MEX Files). Optionally, to read or write MAT-files in your application, use the Write C Programs to Read MAT File Data.
Include files:
engine.h
— Function prototypes for engine routinesmatrix.h
— Definition of themxArray
structure and function prototypes for matrix access routinesmat.h
(optional) — Function prototypes format
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/_`macos`_/libeng.dylib
- Matrix library —
_`matlabroot`_/bin/_`macos`_/libmx.dylib
- MEX library (optional) —
_`matlabroot`_/bin/_`macos`_/libmex.dylib
- MAT-File library (optional) —
_`matlabroot`_/bin/_`macos`_/libmat.dylib
Fortran Engine Applications
To build Fortran engine applications, use the Fortran Matrix API and Call MATLAB from Fortran. If you include Fortran MEX API functions such as mexPrintf in you application, then you must link to the libmex
library. For a list of functions, see Write Fortran Functions Callable from MATLAB (MEX Files). Optionally, to read or write MAT-files in your application, use the Write Fortran Programs to Read MAT File Data.
Include files:
engine.h
— Function prototypes for engine routinesmatrix.h
— Definition of themxArray
structure and function prototypes for matrix access routinesmat.h
(optional) — Function prototypes format
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/_`macos`_/libeng.dylib
- Matrix library —
_`matlabroot`_/bin/_`macos`_/libmx.dylib
- MEX library (optional) —
_`matlabroot`_/bin/_`macos`_/libmex.dylib
- MAT-File library (optional) —
_`matlabroot`_/bin/_`macos`_/libmat.dylib
C MAT-File Applications
To build standalone applications to read data from C MAT-files, use the C Matrix API and Write C Programs 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 Write C Functions Callable from MATLAB (MEX Files).
Include files:
mat.h
— Function prototypes format
routinesmatrix.h
— Definitions of themxArray
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/_`macos`_/libmat.dylib
- Matrix library —
_`matlabroot`_/bin/_`macos`_/libmx.dylib
- MEX library (optional) —
_`matlabroot`_/extern/bin/_`macos`_/libmex.dylib
Fortran MAT-File Applications
To build standalone applications to read data from Fortran MAT-files, use theFortran Matrix API and Write Fortran Programs to Read MAT File Data. If you include Fortran MEX API functions such as mexPrintf in you application, then you must link to the libmex
library. For a list of these functions, see Write Fortran Functions Callable from MATLAB (MEX Files).
Include files:
mat.h
— Function prototypes format
routinesmatrix.h
— Definitions of themxArray
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/_`macos`_/libmat.dylib
- Matrix library —
_`matlabroot`_/bin/_`macos`_/libmx.dylib
- MEX library (optional) —
_`matlabroot`_/extern/bin/_`macos`_/libmex.dylib