Cannot open source file "Mfx.h", #include "Mfx.h"

81 views (last 30 days)
When generating code from a model that uses a minmax block, MATLAB/RTW throws out the following warning.
The model is a SW Component on autosar.tlc target, Matlab 2013b
Warning: The following error occurred while attempting to run the preprocessor to find the minimum needed set of include files:
While parsing the source file 'C:\repository\trunk\src\MySwc\MySwc_autosar_rtw\stub\Rte_MySwc_calib.c' the following error occurred
C:\repository\trunk\src\MySwc\MySwc_autosar_rtw\MySwc.h:22: cannot open source file "Mfx.h"
#include "Mfx.h"
^
Reverting to full header search.
Looking to the generated code I see that there is a library function being used Mfx_Min_u32() to get the minimum between two signals corresponding to the minmax block inside the model.
Anyone knows why this happens? How can I avoid this and get rid of this Mfx_ library?
Thanks.

Accepted Answer

Sandip Kumar
Sandip Kumar on 6 Oct 2014
This is happening because in Configuration Parameters > Code Generation > Interface > Code replacement library is set to AUTOSAR 4.0
Changing it to C89/C90 (ANSI) fixes the issue in R2013b.
With this change, the #include is not there and a basic less than equal to check in included in the generated C code.
The issue has been resolved in latest release i.e., R2014b.
Thanks, Sandip Kumar, MathWorks
  2 Comments
Prashant Asati
Prashant Asati on 31 Aug 2017
Recently I have faced this error. The model is a SW Component on autosar.tlc target, Matlab 2015b. The code is generated with Mfx_ library like below example Mfx_Sub_u16u16_u16(rbp_par_get_hmi_pass_Zone11MiddleDstMin_U16, rbp_par_get_hmi_pass_Zone11CutOffHysteresisMin_u16). While compiling the code getting error ""fatal error #5: could not open source file "Mfx.h" ""
Drew Patton
Drew Patton on 26 Jul 2022
Changine the compiler from Autosar to the alternative (GNU) worked in version 2021b.

Sign in to comment.

More Answers (1)

Chris Wiak
Chris Wiak on 16 Aug 2016
Do you know of a way to halt this warning and make it disappear? I am sure it is possible in the options of the model, not sure which one though. Thanks

Community Treasure Hunt

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

Start Hunting!