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

13 次查看(过去 30 天)
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?

回答(1 个)

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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by