MATLAB: Does the 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)

ccompilationencapsulatedlongsimulink codertimevery

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'.

Best Answer

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.
Related Question