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

13 visualizaciones (últimos 30 días)
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?

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by