I want to generate C code from a Simulink model. My Simulink model has a MATLAB block. In the MATLAB block, I have called external c code with coder.ceval. However, the MATLAB block does not have an equivalent simulation target. I do not want to address any Simulation target but just want to generate equivalent C code from the Simulink block. In the Code Generation settings, I have selected, "Generate Code Only" in Build Process pane. However, I still get the following error when I click "Generate Code" in Embedded/Simulink Coder:
/home/soham/disk1/matlab/bin/mex -R2018a -silent LDFLAGS="\$LDFLAGS " -output samplemodel_sfun.mexa64 @samplemodel_sfun.mol c2_samplemodel.o: In function `sf_opaque_gateway_c2_samplemodel': c2_samplemodel.c:(.text+0x7af): undefined reference to `all_channels'
The `all_channels' is a variable defined in one of the header files, which I do include in MATLAB block with coder.cinclude. Could anyone explain why Embedded Coder calls mex even when I am only generating code and not any executable. How do we skip the Simulation target and only generate C code for target hardware. I want to build the C code with external build environment for the target hardware.