Main Content

Troubleshooting MEX API Incompatibilities

File Is Not A MEX File

For more information, see MEX Platform Compatibility.

MEX File Compiled With Incompatible Options

When you build object files into a MEX function, make sure they are built with the same version of the C or Fortran Matrix API.

This error occurs when you compile two or more files independently with the -c compile-only option, then try to build them into a MEX function. For example:

mex -c function1.c -largeArrayDims
mex -c function2.c -R2018a
mex function1.o function2.o

MEX File Compiled With One API And Linked With Another

This error occurs when you compile a file with the -c compile-only option and then link with a version of the API that is incompatible. For example, if you use the following commands to build a MEX file, then the function errors at runtime.

mex -c function1.c -largeArrayDims
mex function1.o -R2018a

C++ MEX File Using MATLAB Data API Compiled With Incompatible Option

If you create a C++ MEX file using functions in the MATLAB Data API for C++, then the following build command errors.

mex function.cpp -R2017b

Use this command instead.

mex function.cpp

Custom-built MEX File Not Supported In Current Release

MATLAB® does not find a version number in the MEX file. The MEX file uses functions in an API that requires a version number. For more information, see https://www.mathworks.com/matlabcentral/answers/377799-compiling-mex-files-without-the-mex-command.

MEX File Is Compiled With Outdated Option

Your source code is compatible with the interleaved complex API. For best results, replace the mex -largeArrayDims build option with the -R2018a option.

MEX File Calls An Untyped Data Access Function

For more information, see Typed Data Access in C MEX Files.

MEX File Calls A 32-bit Function

For more information, see Upgrade MEX Files to Use 64-Bit API.

MEX File Does Not Contain An Entry Point

For more information, see MEX Platform Compatibility.

MEX File Built In MATLAB Release Not Supported In Current Release

For more information, see MEX Version Compatibility.

Related Topics