Main Content

Invalid MEX File Errors

If MATLAB® cannot find all .dll files referenced by a MEX file, it cannot load the MEX file. For example, suppose MEX file A depends on library subA.dll which is not on the system path. If you call A.mexw64 in folder L:\mylibs\, MATLAB displays:

Invalid MEX-file 'L:\mylibs\A.mexw64':
Missing dependent shared libraries
'subA.dll' required by 'L:\mylibs\A.mexw64'

If a symbol required by a shared library is missing, MATLAB displays a message similar to the following:

Invalid MEX-file 'L:\mylibs\A.mexw64':
Missing symbol 'q' in 'L:\mylibs\subA.dll' required by L:\mylibs\A.mexw64'

To find library dependencies:

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

  • On Linux® systems, use:

    ldd -d
  • On macOS 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 code that loads the libraries controls the search path used to find these libraries. The search path 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. For more information, see MEX Version Compatibility.

  • Missing compiler run-time 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 run-time libraries. Contact your MEX file or library vendor.

Related Topics

External Websites