MATLAB Answers

Why does my generated C++ code take too long to compile if I use Microsoft Visual C++ 2008 Express compiler in Real-Time Workshop Embedded Coder 5.3 (R2009a)?

9 views (last 30 days)
When the tunable parameter size in my Simulink model is very large, the generated code (C++ encapsulated) takes too long to compile. The same model's generated code takes very less time to compile if I set the code generation language to 'C'.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Jun 2021
Edited: MathWorks Support Team on 22 Jun 2021
When there is a very large tunable parameter in the model, the Real-Time Workshop Embedded Coder 5.3 (R2009a) generates C++ code that has huge block parameter data taking huge memory. The Microsoft Visual C++ 2008 (MSVC++) compiler by default can not handle this huge block parameter.
To work around this issue, you can follow the hints suggested by Microsoft:
Basically, the user just needs to supply the /bigobj switch on the compilation command line. One way to achieve this is to right-click the project in Visual Studio, select Properties, and in the pop-up dialog box, select Configuration Properties -> C/C++ -> Command Line, and then add /bigobj to the end of “Additional options:” text box.While this avoids the occurring error, the compilation will last very long anyway.
Another workaround would be to use another compiler. I.e. you could compile the code on a Linux machine, which uses the GNU C++ compiler.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by