Clear Filters
Clear Filters

failed to compile C code with MinGW on windows 10

24 views (last 30 days)
I am trying to build model from simulink (Ctrl + B in Simulink, export to C code) and got an error: "Unable to locate template makefile: rtwsfcnfmi_lcc64.tmf". I am using Matlab 2016b on window 10 platform. I have installed MinGW64 4.9.2 Compiler on my machine, which is supposed to support Matlab 2016b. (The system target file in the parameter configuraiton is rtwsfcnfmi.tlc and the template make file is rtwsfcnfmi_tmf.)
When I had a closer look, the exporting is stuck in the function get_tmf_for_target.m (under \2016b\rtw\rtw). There is one line called comp = rtwprivate('rtwParallelBuildCompiler','get'); The value I got is comp=0, looks very much matlab could not find a compiler. However, when I check the compiler installtion with mex -setup -v, it seems that the compiler is installed correctly and I got the following message:
... Looking for compiler 'MinGW64 Compiler (C)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\mingw-w64\x86_64-4.9.2-posix-seh-rt_v4-rev4\mingw64\').
... Looking for file 'C:\mingw-w64\x86_64-4.9.2-posix-seh-rt_v4-rev4\mingw64\bin\gcc.exe' ...Yes.
... Looking for folder 'C:\mingw-w64\x86_64-4.9.2-posix-seh-rt_v4-rev4\mingw64' ...Yes.
Found installed compiler 'MinGW64 Compiler (C)'.
So I am wondering what caused the error? I notice that MigGW64 does not support Matlab compiler nor Matlab compiler SDK for version 2016b, could that be the reason?

Answers (1)

Pinkesh Narsinghani
Pinkesh Narsinghani on 5 Mar 2019
This can happen in the following situations:
1) the compiler settings are not set to default in the custom template makefile (i.e., you have not specified any particular compiler/toolchain within the TMF)
2) there is mismatch between the compiler set with mex -setup and the compiler tool chain specified within the TMF. For instance:
>> mex -setup
MEX configured to use 'Microsoft Visual C++ 2013 (C)' for C language compilation
but in the TMF:
COMPILER_TOOL_CHAIN = lcc
In order to avoid this, you should specify:
COMPILER_TOOL_CHAIN = default
in the TMF.
*TMF is Template Makefile
  1 Comment
Shoaib Shaikh
Shoaib Shaikh on 31 Mar 2020
I am trying to generate FMU from Matlab R2017b and get this error as well.
In FMIKit, I found the files with .tmf extension. I modified the tool chain compiler and set it to ‘default’ in all the files.
In the Toolchain settings in the model, the option ‘Automatically locate an installed toolchain’ is selected. I have MinGW64 Compiler (C) installed on my system.
But I get the same error after I build to generate the FMU.

Sign in to comment.

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!