Matlab Coder - How to generate C++ header files in different directory than source files?

Is there a way to configure Matlab Coder to output the header files into a user specified location that is different than the source files?
I am using Coder to generate C++ code from my matlab code. The generation works fine. However, the header files (*.h) are in the same directory as the source files (*.cpp). In my application we keep the header files (include) and source files (src) separate. The issue is that without being able to specify the include directory, all of the #include statements do not have the correct path to the header file. I can manually change them all, but that is annoying especially if there is a lot of iteration between matlab and C++ code deployment. It would be preferable for Coder to just add a "path" in front of the code when it is generated. I searched but could not find a solution. Is this ability possible?

Réponses (1)

You could do this with a simple MATLAB script that runs the codegen command and then moves .h files to desired location.

3 commentaires

Maybe I did do a good job explaining my issue. It is not the moving of the files that is the issue. It is that all of the #include statements will be wrong if the header files are in a different directory.
There is no way to change the #include statements inserted in the generated code to reference a new location. However, you can direct your C/C++ compiler to look in the other directories, usually with the "-I" compiler switch.
Ok, thanks for the confirmation.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Coder dans Centre d'aide et File Exchange

Produits

Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by