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.

Invalid MEX File Error

If MATLAB® cannot find all .dll files referenced by a MEX file, it cannot load the MEX file. MATLAB displays the following error message:

Invalid MEX-file <mexfilename>:
The specified module could not be found.

where mexfilename is the module with the dependency error. This module cannot find its dependent libraries. To resolve this error, find the names of the dependent libraries, and determine if they are present on your system and on the system path.

To find library dependencies:

  • On Windows® systems, download the Dependency Walker utility from the website

  • On Linux® systems use:

    ldd -d
  • On Mac OS X systems use:

    otool -L libname.dylib

For .dll files that the MEX file linked against when it was built, the .dll files must be on the system path or in the same folder as the MEX file.

MEX files might require additional libraries that are not linked to the MEX file. Failure to find one of these explicitly loaded libraries might not prevent a MEX file from loading, but prevents it from working correctly. The search path used to find these explicitly loaded libraries is controlled by the code that loads the libraries and might not include the folder that contains the MEX file. Consult the library documentation on proper installation locations.

Possible reasons for failure include:

  • MATLAB version incompatibility

  • Missing compiler runtime libraries. If your system does not have the same compiler that built the MEX file, see the Microsoft® MSDN® website for information about Visual C++® Redistributable Packages.

  • Missing or incorrectly installed specialized runtime libraries. Contact your MEX file or library vendor.

Was this topic helpful?