How to integrate codegen generated multiple different C projects using calls to generated functions?
4 ビュー (過去 30 日間)
古いコメントを表示
As far as I know through internet searching, in order to fuse multiple code/functions generated by codegen in one big project, you can either integrate different C++ code projects into one bigger project or codegen commands specify multiple entry signature functions at the same time.
But the problem I am having is how to integrate multiple different C projects into one big project? There are a lot of functions with the same name, for example, <myProject1_emxutils.h>,<myProject2_emxutils.h> files have the function with the same name that defines `emxInit_int32_T(emxArray_int32_T **pEmxArray)`, in this big C project when I call main entry function function myProject1() there are problems, like memory problems at the moment of running, "free(): invalid next size (fast)", how to solve it? Or a workaround?
0 件のコメント
採用された回答
Denis Gurchenkov
2023 年 9 月 18 日
編集済み: Denis Gurchenkov
2023 年 9 月 19 日
Hi cui,
The memory issues you describe can happen if both projects contain some unnamed structu types (that is, types that do not posses unique name attached to them using coder.cstructname) - in that case, the emx* functions could be named identically but contian different data, and a memory corruption would occur if you just merge the projects together.
One known workaround is to add unique prefixes to the name of functions generated in each project (this requires the Embedded Coder product license):
cfg = coder.config(‘lib’);
cfg.CustomSymbolStrEMXArrayFcn = ‘proj1_emx$M$N’;
... now generate code using this config, e.g. codegen.... -config cfg....
Another workaround is to generate C++ code and use seprate namespaces.
2 件のコメント
Denis Gurchenkov
2023 年 9 月 19 日
編集済み: Denis Gurchenkov
2023 年 9 月 19 日
I was wrong when I said there is no workaround. Cui, can you please try the following, and see if it helps?
cfg = coder.config(‘lib’);
cfg.CustomSymbolStrEMXArrayFcn = ‘proj1_emx$M$N’;
now generate code with this config. You should see generated code has unnique prefixes for all emx functions Now, for the next project, change the prefix. This config parameter requires Embedded Coder license.
I understand this is not the perfect solution. But, does this work for your use case?
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!