Invalid MEX-file: The specified module could not be found.
Mostra commenti meno recenti
Update: I copied the .dll file to the same directory as the mexw64 file, and the script seems to run fine. However, Matlab crashes everytime after this step (crash log posted in the comment section):
INIT STARTEDSetting debug on
matleap version 4.0
Could anyone please advice me on what can be happening here? Thank you so much!
Hello! I am trying to wrap C++ data into Matlab by making a mex-file. I got the following error when I was testing the mex file that I built:
Invalid MEX-file 'C:\Users\...\OneDrive - ...\PROJECT\Leap Motion\matleap\matleap.mexw64': The specified module could not be found.
Error in matleap_version (line 3)
v=matleap(0);
Error in test_matleap (line 12)
[version]=matleap_version;
I checked and .dll file is added to the path when I run the test. Could anyone please give me some advice on what could be the problem? I saw in some previous questions that I should use dependency walker, but that application is just not responding when I try to open a the mex file in it.
14 Commenti
Bruno Luong
il 25 Mar 2024
Are you trying too run the mex file on the same computer where it is built?
James Tursa
il 25 Mar 2024
Can you post your wrapper code?
Julia
il 25 Mar 2024
Julia
il 25 Mar 2024
Julia
il 25 Mar 2024
James Tursa
il 25 Mar 2024
Modificato: James Tursa
il 25 Mar 2024
Can you try a manual build? E.g., something like:
mex matleap.cpp LeapConnection.cpp LeapSDK.lib -R2018a
where all the required files are in the same directory. Or maybe
mex('matleap.cpp','LeapConnection.cpp','(full directory path)/LeapSDK.lib','-R2018a')
Bruno Luong
il 25 Mar 2024
@Julia "This error was detected while a MEX-file was running. If the MEX-file"
I though the MEX file cannot be run since "Invalid MEX-file" was reported orginally, now it runs and crashes? What have you changed?
James Tursa
il 25 Mar 2024
Modificato: James Tursa
il 25 Mar 2024
@Bruno Luong It looks like the mex routine compiles and starts, and this is a run-time error. E.g., there is maybe some output to the screen before crashing (is this coming from the mex routine?). Can't find a routine in a DLL or LIB file, etc. Could be the result of linking with wrong library files? Or maybe a compiler setting is incorrect?
Julia
il 25 Mar 2024
Julia
il 25 Mar 2024
Bruno Luong
il 26 Mar 2024
Modificato: Bruno Luong
il 26 Mar 2024
But that is the crucial change, by copying the dll file, now your MEX file can load the DLL and starts correctly.
Now why it crashes. This is entirely diffrent issue. You have to ask the author or debug yourself the mex file. Unless if it crashes inside the DLL and LIBRARY without the source code available, the it is not possible to debug.
The error message suggests
"If the MEX-file is not an official MathWorks function, please examine its source code for errors. Please consult the External Interfaces Guide for information on debugging MEX-files."
The cause of the bug can be anythihg, I doubt anyone can help you from now.
In the MEX command you haven't provide the value of "libdir_switch" hard to tell if the roll standalone mex command does the same.
Julia
il 27 Mar 2024
Bruno Luong
il 27 Mar 2024
Modificato: Bruno Luong
il 27 Mar 2024
The purspose of -R2018a switch is to cope with change of internal storage: interleaved complex number storage and accesory using some mxGetxxxx API, This major change of internal happens in R2018a. however your mex compile without the flag, so those API are not used.
There is not such switch as -R2023b.
You should add -R2018a switch if you use direct mex command. But I believe the effect would be only accelerate the code execution, since no data copying (hidden to user) if mxGetData, mxGetPr, mxGetPi is performed in theory.
Julia
il 9 Apr 2024
Risposte (0)
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!