Invalid MEX-file: A dynamic link library (DLL) initialization routine failed.
23 ビュー (過去 30 日間)
古いコメントを表示
For building a mex file, I implemented a C++ class and overloaded the operater() operator.
However this C++ file does also contain a global variable, which also makes sense in this particular use case. Unfortunately I face some problems when calling the compiled mex function from matlab. Except at some very rare cases where everything works as expected, I usually get the fallowing error in the MATLAB console wenn calling the mex function:
Invalid MEX-file '<path>\<MexName>.mexw64': A dynamic link library (DLL) initialization routine failed.
The error is thrown after a long (approx 30 sec) MATLAB freeze . Sometimes the MATLAB IDE even crashes down.
This error does never occur if i build the same C++ mex without this global variable. Restarting MATLAB, the computer, or clear('all') does not help.
I use Microsoft Visual C++ 2017 and Microsoft Visual C++ 2019 compiler and MATLAB R2019b
0 件のコメント
回答 (1 件)
Samay Sagar
2025 年 2 月 28 日
It is unlikely that the usage of global variable is the cause of the above error. I have tried building a MEX file for a C++ function that uses global variables, which runs without any error in MATLAB R2019b. To diagnose this issue, you can try building your MEX file with the verbose options enabled. This can help you to identify any compilation errors and the possible cause of the issue. You can use the "-v" flag to enable verbose output as follows:
mex -v fileName
Execute the following command in your MATLAB Command Window to learn more about the usage of various flags with "mex" function:
doc mex
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!