With an ert.tlc based target, the typical workflow normally includes the rt_main.c (for applications using the static main module and portable for multiple platforms) or the ert_main.c (as an example application for a chosen platform) so executable can be generating without missing the 'main' function. Therefore, when you check "Generate an example main program", the ert_main.c will be generated. When you uncheck that option, the rt_main.c (together with rtwmodel.h) will be included. More details about such deployment mechanism can be found here:
Either way, they are captured in the buildInfo.mat file. The 'packNGo' function uses the buildInfo.mat to find all needed files.
Therefore, if we remove the 'ert_main.c' or 'rt_main.c' entry in the 'buildInfo' variable saved in the buildInfo.mat file, 'packNGo' will not include them in the ZIP file. When passing the modified 'buildInfo' to 'packNGo', make sure that there is no other buildInfo.mat file presented in the current working directory as that stale file could override the modified 'buildInfo'.
There are two possible workflows of utilizing the above fact to exclude the (e)rt_main.c file from the ZIP package. In both cases, the attached script removeExampleMain.m will be used.
1) Use the Post code generation command parameter. Here, we are calling the modifying script during the code generation process, so the generated buildInfo.mat file is already free of the main files. In order to do that, go to Configuration Parameters and search for 'Post code generation command parameter', use 'removeExampleMain' as the value. Save the configuration and generate code. Once the code is generated, load the buildInfo.mat file and do 'packNGo' with the loaded 'buildInfo' variable. Note, if there is an existing buildInfo.mat file under the current working directory, you need to delete it before running 'packNGo'.
2) Run the script right before 'packNGo'. In this case, you do not need to modify the model. Generate the code and load the generated buildInfo.mat file. After that, run 'removeExampleMain' before running 'packNGo'.
Best Answer