"File is not a mex file" error despite the settings seeming correct

44 次查看(过去 30 天)
I am trying to follow the Matlab examples on using mex. I first run
copyfile(fullfile(matlabroot,"extern","examples","mex","yprime.c"),".","f")
and this works, copying the file. I then run
mex yprime.c
which gives me the output
Building with 'MinGW64 Compiler (C)'.
Error using mex
'yprime.mexw64' is not a MEX file. For more information, see File is not a MEX file.
I have ensured that I am using the correct version of the compiler (6.3.0). I am using a 64-bit operating system with 64-bit MATLAB, and running
mexext
returns mexw64 as expected. So I am not sure what the issue could be. I have looked in the "see File is not a MEX file" section of the help and it did not help me resolve the issue.
  1 个评论
dpb
dpb 2024-10-4,21:20
There apparently is at least one other way to generate the message than just the wrong extension...
I haven't tried mex'ing anything in years since they quit supporting any Fortran compiler other than Intel...

请先登录,再进行评论。

回答(1 个)

Shivam Gothi
Shivam Gothi about 5 hours 前
Hello @Elliott
I have executed the code you provided in MATLAB R2022b, without encountering any errors. However, I have identified a few workarounds that might help resolve the issue.
Cause of the error:
If MATLAB cannot find all .DLL files referenced by a MEX file, it cannot load the MEX file. 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, find the names of the dependent libraries, and determine if they are present on your system and on the system path.
For windows operating system, you can use “Dependency Walker Utility”.
Dependency Walker is a tool that tracks and logs files that are accessed when an executable launches. It can also track what files are being called by a DLL or SYS file. It is able to track file registration errors, access violations, invalid page faults or even missing files. It can be downloaded from the website:
Refer to the below documentation to get more detailed explanation:
To know more about “Dependency walker utility”, refer:
you can also refer to the below MATLAB answer, which addresses the similar issue:
I hope it helps!

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by