MATLAB Answers

1

Why do I receive a "specified module could not be found" error while running a MEX-file created from MATLAB 7.0.1 (R14SP1)?

When I try to run a MEX-file I created, I receive the following error:
??? Invalid MEX-file 'MEX-file name': The specified module could not be found.
where "MEX-file name" is the name of my MEX-file. However, I did not receive any errors when compiling the file.

Products


Release

R14SP1

3 Answers

Answer by MathWorks Support Team on 18 Oct 2013
 Accepted Answer

This change has been incorporated into the documentation in Release 2013a (R2013a). For previous releases, read below for any additional information:
This error can occur if you do not have all of the necessary DLL files that the MEX-function is dependent upon or if you are running a MEX-file on a different version of MATLAB than it was compiled on.
In order to view dependent DLL files and help locate the source of this error, you may use the third-party product "Dependency Walker". The Dependency Walker can be downloaded from the following web site:
Kindly refer to the attached solution below for more information on how to use the Dependency Walker to profile your MEX file.
After finding the missing dependent module, add it to the directory where the MEX file resides or add it to the system search path.

  3 Comments

A word of caution about the dependency walker:
I just wasted a few minutes looking for some files that it reported missing from my Windows 7 machine:
API-MS-WIN-CORE-COM-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL
DCOMP.DLL
GPSVC.DLL
IESHIMS.DLL
These are likely not the issue (see http://stackoverflow.com/questions/17023419/win-7-64-bit-dll-problems) for a missing dependency. (The dependency walker may still be helpful for your problem, just ignore those particular files).
Chad,
Thanks for the info. I also found libmex.dll and libmx.dll in the list reported by dependency walker and these weren't the problem either (for obvious reasons, perhaps).
-Eric
It would be much more helpful if the error message said which module was missing.

Sign in to comment.


Answer by Jim Hokanson on 18 Jun 2014

In my case I needed to install a Visual Studio redistributable Package that matched the version used when compiling the libraries I was linking against. A Google search "Visual Studio redistributable 2012" provided the link to the installer I needed. Once this was installed I could compile directly from Matlab. I am guessing that if I had compiled from inside visual studio instead of from within Matlab things would have worked as well.

  0 Comments

Sign in to comment.



Hello, I've solved putting these files in the same folder of the mex file:
libgcc_s_seh-1.dll
libgomp-1.dll
libgomp-plugin-host_nonshm-1.dll
libwinpthread-1.dll
Best regards, Ulisse

  2 Comments

Putting libgcc_s_seh-1.dll in the same folder as mex file solved the problem for me. Thanks.
Hello there, i have the same problem! but i dont have those files at all! could someone post them to me or send them on sanaasal11@gmail.com or mention a source i could get them from?

Sign in to comment.