How to setup C/C++ Compiler for code generation using MATLAB Coder for MATLAB R2015b?

6 views (last 30 days)
I am seeing a Code 2 build error when trying to generate code using MATLAB Coder. Why am I seeing this? Is it because I don't have a C/C++ compiler installed? If so, how do I install one for MATLAB R2015b to setup code generation using MATLAB Coder?
Also, can I generate code for multiple entry point functions?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Jan 2018
Yes, this error occurs either because there is no C/C++ Compiler installed, or there is one installed and it has not been setup for code generation in MATLAB. Please find a list of supported compilers for MATLAB R2015b below:
Please follow the steps provided below to setup MATLAB Coder for C Code Generation:
  • Install a supported C/C++ compiler, as specified in the link above. Please skip this step if you already have a supported compiler installed. For the purpose of this article, we have provided a link to the Windows SDK 7.1 with  .NET framework 4.0 compiler, which is supported for MATLAB R2015b. Please find the link to the installation file below:
         NOTE - In case there any issues during the installation process, specifically if you observe an 'Installation Failed' error message, please refer to the following link:
         <http://www.mathworks.com/matlabcentral/answers/95039-why-does-the-sdk-7-1-installation-fail-with-an-installation-failed-message-on-my-windows-system>
  * Please run the following command at the MATLAB Command Window:
                >> mex -setup
_         This command will locate all the C/C++ Compiler installed on the machine and allow you to set one as the default compiler for code generation. For more information on this command, please refer to the link:
         <http://www.mathworks.com/help/matlab/ref/mex.html?searchHighlight=mex%20-setup>_
  • MATLAB has now been setup for code generation.
With regards to the 2nd question, MATLAB Coder can be used to generate code for multiple entry-point functions. When adding an entry-point function in the MATLAB Coder app, there is an option to add more entry-point functions. 

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

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

Start Hunting!