This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Run MEX File You Receive from Someone Else

To call a MEX file, put the file on your MATLAB® path. Then type the name of the file, without the file extension.

If you have MEX file source code, see Build MEX File for information about creating the executable function.

If you get runtime errors when you call a MEX file that you did not create, consider the following:

  • Platform Compatibility

  • Version Compatibility

  • On Windows® platforms, install the C++ compiler runtime libraries used to create the MEX file. This step is needed if you do not have the same compiler installed on your machine that was used to compile the MEX file.

  • If the MEX file uses specialized runtime libraries, those libraries must be installed on your system.

If you write a MEX file, build it, and then execute it in the same MATLAB session, all of the dependent libraries are available, as expected. However, if you receive a MEX file from another MATLAB user, you might not have all of the dependent libraries.

A MEX file is a dynamically linked subroutine that the MATLAB interpreter loads and executes when you call the function. Dynamic linking means that when you call the function, the program looks for dependent libraries. MEX files use MATLAB runtime libraries and language-specific libraries. A MEX file might also use specialized runtime libraries. The code for these libraries is not included in the MEX file; the libraries must be present on your computer when you run the MEX file.

For troubleshooting library dependencies, see Invalid MEX File Error.

For information about how MATLAB finds a MEX file, see Files and Folders that MATLAB Accesses.

Was this topic helpful?