How to integrate codegen generated multiple different C projects using calls to generated functions?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
cui,xingxing
am 18 Jul. 2023
Bearbeitet: Denis Gurchenkov
am 19 Sep. 2023
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 Kommentare
Akzeptierte Antwort
Denis Gurchenkov
am 18 Sep. 2023
Bearbeitet: Denis Gurchenkov
am 19 Sep. 2023
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 Kommentare
Denis Gurchenkov
am 19 Sep. 2023
Bearbeitet: Denis Gurchenkov
am 19 Sep. 2023
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?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!