How to fix error "Invalid MEX-file, The specified module could not be found. "

조회 수: 50 (최근 30일)
Chloë
Chloë 2025년 9월 30일
답변: Chloë 2025년 10월 18일 23:21
When I try and run a Simulink this error appears, (for simplicity’s sake I have replaced names and locations with placeholders). Both the MEX file, Simulink and any associated MATLAB code were not created by me and I have limited accesses to the inner workings.
Error while obtaining sizes from MEX S-function 'filename' in 'simulink location'.
Caused by:
Invalid MEX-file 'C:\filepath\filename.mexw64': The specified module could not be found.
I have been poking at this for a while now and have tried several recommended actions to resolve this; downloading a complier (MinGW-w64 C), checking file path (the MEX file is definitely present), installing all add-ons and toolboxes I know I need. I've used MATLAB's dependency analyser, and the MEX file isn't showing up even though they are in the folder being analysed. I have also clumsily used a dependency walker, and nothing looks worrisome but I don’t really trust my skill when using it.
The same setup processes has been followed and completed successfully on other devices, without any extra steps. So, I must admit I'm at a bit of a loss here.
If anyone has any advice, I would love to hear it.
  댓글 수: 2
Walter Roberson
Walter Roberson 2025년 9월 30일
The specified module could not be found typically indicates that a dependancy is unavailable.
dpb
dpb 2025년 10월 1일
Particularly given OP said "Simulink and any associated MATLAB code were not created by me" it's quite possible the mex file was compiled on a different system or with a different compiler/version. If so, it may have dependencies that are incompatible or missing on the OP's system. In that case, recompiling the mex-file on the target system may be the only recourse.
If have Visual Studio, from the Developer command prompt use
dumpbin /dependents "theMEXfile.mexw64"
and check for all dlls and versions thereof. It's a fair bet the original system uses some compiler-installed runtime DLLs that didn't get moved over.

댓글을 달려면 로그인하십시오.

채택된 답변

Chloë
Chloë 2025년 10월 18일 23:21
I have managed to fix this problem for me so I'm just going to outline my steps below so it's all in one place for anyone else with the issue.
first I ran this dependency analyser GitHub - lucasg/Dependencies: A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot dll load dependencies issues. (Instead of Dependency Walker (depends.exe) Home Page which was more commonly recommended) This threw less false positives and also had a clearer layout.
This outlined I was missing MSVCR110.dll. My first attempt to get this dll was to install Visual C++ Redistributable and I installed both variants (32-bit and 64-bit) as recommended by other sources but unfortunately this didn't work. I also tried all step located here How To Fix Microsoft Visual C++ DLL Files Missing. Through my research this will likely work for most people but I was still facing the issue.
In the end I took a copy of a friend’s dll via memory stick and manually put that in window/system32 which finally caused my MATLAB code to work. I wouldn’t recommend installing any dlls from any websites.
This took me approximately 3 weeks to sort out so I thought it would be helpful to put all this information in one place for anyone else tearing their hair out like me

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

태그

제품


릴리스

R2025b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by