Matlab Coder on Mac won't overwrite mex file

I have a script which compiles a certain matlab function (NW3.m) to a mex file using Matlab Coder each time I run it. (I have it re-convert the matlab function to a mex file because the size of the inputs change depending on the run of the script). This works perfectly on windows, but on the mac side it won't overwrite the old mex file each time the script runs. Instead, it creates in the current directory a new sub-directory ../matlab/codegen/mex/NW3/ and it places the mex file in there. Any ideas on how to force it to overwrite the file in the current directory?
What I do right now is go in and manually delete the last .mex file created in the current directory before each run the of the script, but it is a pain.

댓글 수: 4

Does it help if you call "clear mex" between runs?
Hi Joseph,
MATLAB Coder always creates a .mex file inside ./matlab/codegen/mex/NW3, and then copies it to the current directory, unless the "-d" option instructs it to place the file somewhere else. Please try "clear mex" to make sure the .mex file in the current folder is not locked, and also please check the permissions on the old .mex file, maybe Coder is unable to overwrite the file for some reason. Please let us know whether this helps. -- Denis
Joseph Cullen
Joseph Cullen 2012년 7월 11일
편집: Joseph Cullen 2012년 7월 11일
clear mex does not work. I still have to manually delete the mex file between iterations. Any other ideas?
I did check the file permissions which have read/write capabilities. I don't know how else to check if a file is "locked" on OSX.
Hi Joseph,
I admit I do not understand how can this happen. There is no platform-specific behavior in the codegen command, and in my experiments, the mex file is always copied, if the permissions allow it. I still think there is something wrong with permissions, maybe the folder permissions are wrong (do not allow the file to be created)...
As a workaround, can you try using the "-d" option to instruct codegen to place the generated mex file somewhere else (outside of the problem folder), does that help?
Denis.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

태그

질문:

2012년 6월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by