MATLAB: Can I compile C++ MEX-files, ENGINE programs, or MAT-file programs using MATLAB

cenginematMATLABmex

I would like to have the ability to compile C++ MEX-files, ENGINE programs, or MAT-file programs using MATLAB.

Best Answer

As of MATLAB 7.0 (R14), MEX should handle C++ MEX-files, Engine programs, or MAT-file programs. If you are using a previous version of MATLAB, please see the following:
We have not officially tested the use of C++ MEX, ENGINE, or MAT-files. It appears that in most cases for MATLAB 5.3 and higher, C++ is compatible. However, there are some known platform, compiler, and code dependent issues.
To compile C++ MEX-files, ENGINE programs, or MAT-file programs, you must let your C Compiler know that you are compiling a C++ file. If you are compiling with the 'mex' command and using our options files, you would need to add the following to your COMPFLAGS option in your options file:
-DNO_BUILT_IN_SUPPORT_FOR_BOOL
If you are compiling in the IDE, you must be sure to add the pre-processor directive:
NO_BUILT_IN_SUPPORT_FOR_BOOL
to the CFLAGS as part of the pre-processor directive field of the IDE for your particular C compiler.
For more information regarding C++ MEX-files, see Technical Note 1605: MEX-files Guide.