Error: Invalid MEX file, the specified module could not be found

anand picture anand · Mar 11, 2013 · Viewed 17.4k times · Source

I have compiled Mex file successfully on my laptop. But when I am running it, it says Invalid mex file 'c:\newfolder\filename.mexw32' The specified module could not be found.

System specification:  
OS: windows 7  
MATLAB 2010a  
Microsoft Visual Studio 2008.  

The same mex file is compiled and run successfully on my PC under XP SP3.

Answer

Eitan T picture Eitan T · Mar 11, 2013

This MathWorks support link suggests two possible reasons to your problem:

  1. You do not have all of the necessary libraries that the MEX-function is dependent upon.
  2. You are running a MEX-file on a different version of MATLAB than it was compiled on.

Either way, to locate the source of this error it says that you need to list all dependent library files and verify their existence in the system you're trying to run the MEX file on, and also recommends the Dependecy Walker as the tool to to do that.