How to integrate codegen generated multiple different C projects using calls to generated functions?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
cui,xingxing
el 18 de Jul. de 2023
Editada: Denis Gurchenkov
el 19 de Sept. de 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 comentarios
Respuesta aceptada
Denis Gurchenkov
el 18 de Sept. de 2023
Editada: Denis Gurchenkov
el 19 de Sept. de 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 comentarios
Denis Gurchenkov
el 19 de Sept. de 2023
Editada: Denis Gurchenkov
el 19 de Sept. de 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?
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!