MATLAB® fails to load binary MEX-files if it cannot find all .dll files referenced by the MEX-file. When this happens, 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, you must find the names of the dependent libraries, and determine if they are present on your system and available on the system path.
On Windows® systems, to find library dependencies, use the third-party product Dependency Walker. Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions exported by that module, and which of those functions are called by other modules. Download the Dependency Walker utility from the website http://www.dependencywalker.com/. See http://www.mathworks.com/matlabcentral/answers/92362-how-do-i-determine-which-libraries-my-mex-file-or-stand-alone-application-requires for information on using the Dependency Walker.
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 will prevent 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.