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

5 vues (au cours des 30 derniers jours)
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)

Mark McBroom
Mark McBroom le 18 Nov 2023
You could do this with a simple MATLAB script that runs the codegen command and then moves .h files to desired location.
  3 commentaires
Mark McBroom
Mark McBroom le 21 Nov 2023
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Coder dans Help Center 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