Error Compilng C++ MEX File

11 ビュー (過去 30 日間)
Keith Sullivan
Keith Sullivan 2016 年 12 月 6 日
コメント済み: Shubham Jadhav 2024 年 4 月 3 日
Hello, I'm trying to develop a new MEX file and can only compile the file one time before an error appears. I can successfully compile the file from the MATLAB command prompt one time upon launch of MATLAB. Subsequent attempts to compile the file produce an error message
'myfile.mexa64' is locked by the MexLock API
The only solution I've found so far is to restart MATLAB. Any suggestions on how proceed? Or what is causing the error upon compilation? Everything I've read about locking Mex files refers to runtime functions, not compilation.
Thanks Keith
  1 件のコメント
Shubham Jadhav
Shubham Jadhav 2024 年 4 月 3 日
I had faced the similar issue and the reason is,I was running simulation in steps (which required "that" mex file) and I trying to mex for the same s-function.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2016 年 12 月 6 日
編集済み: Jan 2016 年 12 月 6 日
The "MexLock API" is triggered by the command mexLock. If this is called inside the Mex-function, this file is locked. You have to release it by using an internal method, which calls mexUnlock. Without such a method, restarting Matlab is the only solution.
Perhaps this helps:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
if (nrhs == 0) {
mexUnlock();
return;
}
...
}
Now calling the MEX function without inputs unlocks it.
But, well, why do you lock the Mex at all?
[EDITED] If clear mex does not help also, please post more details. Do you compile the mex file in an UNC path? If so, try it on a drive with drive letter.
  2 件のコメント
Keith Sullivan
Keith Sullivan 2016 年 12 月 6 日
I don't lock the file. mexLock is not called anywhere in the code. Is there another way to lock a file without explicitly calling mexLock?
Jan
Jan 2016 年 12 月 9 日
See [EDITED]

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by