How to integrate codegen generated multiple different C projects using calls to generated functions?
조회 수: 3 (최근 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!