MATLAB: Does some of the header files (like ippreconstruct.h and tmwtypes.h) are not generated, although they are included in the source code (using #include), in MATLAB Coder

matlab coder

I have a simple MATLAB code containing some of the commands like 'imfill', 'pdarray', etc. When I am generating code from this using MATLAB Coder then I can observe that some of the files although included in the source code (.C code) using the #include tag but those files are not generated as part of the code generation.
Code snippet which show the files included are:
#*include* "ippreconstruct.h"
#*include* "tmwtypes.h"
The above header files although included in the .C file but are not generated. So when I am using the generated code to compile them in some other application (say Visual Studio), I get the error that these header files are missing.
However, I can observe that some of the other MATLAB specific header files like ‘rtwtypes.h’ do get generated along with the other main source codes.
Reproduction steps:
1. Start MATLAB coder using the below command in MATLAB R2013b:
>> coder
2. Include the MATLAB file under the ‘Entry-Point Files’
3. Under the ‘Build’ tab choose ‘Output type’. (say ‘C/C++ Executable).
4. Click on ‘Build’ button.
5. Check the Code Generation Report for the generated code.
Please note: I am attaching the sample MATLAB code (fillholes_test.m) with this article.

Best Answer

The header files are missing from the generated files because all the files which are a part of MATLAB installation (present in the ‘MATLABROOT\extern\include’ directory) does not get copied in the folder of the generated code.
It is expected that since these files are already available in the MATLAB directory, to compile these files we just need to include the path of these files in the ‘include’ directory of the external compiler.
In contrast, other MATLAB files (like rtwtypes.h) are generated because these files are not available in the MATLAB installation directory. These files are customized to the specific project for which code is generated and are not generic files.
As a workaround, to get all the files in the generated directory, package option can be used which will create a ZIP folder with all the files included. This option can be used if the generated code need to be relocated to another development environment. For details on this please refer to the below link:
In addition, the necessary files to include in the external compiler may be found in the MK file, if the Coder is set to generate one.