필터 지우기
필터 지우기

How do I make compiled mex files take precedence over m files when using Matlab Compiler?

조회 수: 6 (최근 30일)
Normally when executing Matlab code, compiled mex files take precedence over m files. So if you have an .m and a compiled mex file, the compiled mex file will be called. Therefore, when using mex files a useful pattern which helps end users is to include an .m file for each mex file, where the .m file displays a message to the user altering them that the mex file has not been compiled. This is useful because otherwise it is hard for the end user to understand the cause of the error.
However, it seems that Matlab Compiler (mcc) has the opposite precedence; i.e. when compiling a function using mcc - m, if a mex file is invoked in the function, but a corresponding .m file exists, then the compiled mex file will be ignored and the .m file will be called instead. So with the above pattern, no compiled mex files will be included and all calls to mex files will fail. In other words, the Matlab Compiler has a different precedence behaviour to the Matlab interpreter.
Is there any way to force the Matlab Compiler mcc to include the compiled mex files in preference to .m files, to match the precedence behaviour of the interpreter? (Other than manually deleting all the corresponding .m files?)

답변 (3개)

Sean de Wolski
Sean de Wolski 2016년 10월 11일
Are you adding the MEX files to the CTF with the -a option in mcc (or as "Other files" in the app)?
  댓글 수: 1
Tom
Tom 2016년 10월 18일
I'm using mcc with -a to specify the folders containing the .m and compiled mex files. It seems that if an .m file exists anywhere in the compilation search path, it overrides the compiled mex file.

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


Tom
Tom 2016년 10월 18일
As a workaround I have moved the .m files into a separate folder and made sure that folder is removed from the Matlab path and all of the search paths specified with -a when I call mcc to compile. I also have to exclude all parent folders since -a is recursive. This is not really a fix because the behaviour is inconsistent with Matlab's interpreted behaviour, but it gets the compiled app working and calling the compiled mex files correctly.

Hazem
Hazem 2018년 8월 30일
I use the app (from the Apps tab):
Application Compiler
There, you can manually add the mex-files in the box:
Files required for your application to run
if they are not already there. For me, they were automatically detected with Matlab compiler version 9.01

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by