Do I need to recompile MEX if I edit a function?
1 view (last 30 days)
Tommi Muller on 23 Jul 2020
Let's say I have a MATLAB function "fun1", which calls another MATLAB function "fun2".
I then run the MATLAB Coder on fun1 and compile it into MEX code. Then later, I edit fun2. Does fun1 need to be recompiled again?
I am in this situation now and after editing fun2, it seems that fun1 is still running fast and its outputs reflects the changes made in fun2. But I want to be sure that I do or don't have to recompile fun1 again.
Darshan Ramakant Bhat on 24 Jul 2020
When you generate code for "fun1" (which is called as "entry-point function" in code generation terminology), codes will be generated for underlying functions as well in a recursive manner.
So if you modify any function which is called from entry point function, the MEX needs to be re-compiled.
Special Case :
The above mentioned details are not true when you call a function by making it "extrinsic" function. Coder pragma coder.extrinsic is used to declare a function as extrinsic :
When you declare a function as extrinsic, the generated code will call back to MATLAB to execute the function in MATLAB. So if you modify a function which is extrinsic, it may take effect without recompiling as well. But declaring a function as extrinsic will come with a performance hit.