Azzera filtri
Azzera filtri

How can I avoid conflicting function names in two different static libs. when using MATLAB Coder?

7 visualizzazioni (ultimi 30 giorni)
I use the fopen fclose functions in my MATLAB code int wo different project (two static libs). The generated code includes different implementations of these function (cfclose cfopen) but use the same name. This becomes a problem for the linker when using the two libraries in my main application.
How can a control the namegiving of the functions when I code generate?

Risposte (1)

Infinite_king
Infinite_king il 1 Dic 2023
Modificato: Infinite_king il 1 Dic 2023
Hi Christer Nykvist,
I understand that you are trying to use multiple static libraries which has been generated using MATLAB Coder.
The default Code generation configuration will generate the code without using namespaces. We can instruct the MATLAB Coder to generate the code in such a way that it places all the generated functions in a specific namespace. We can use this feature to place the functions generated by MATLAB Coder in different projects in their own respective namespaces. This will resolve any naming conflicts.
To use namespaces, set the following configuration parameters as follows,
% Project 1 configuration
cfg = coder.config('lib'); % choose required target
cfg.TargetLang = "C++";
cfg.CppNamespace = 'namespace1'; % Namespace name
% Project 2 configuration
cfg2 = coder.config('lib'); % choose required target
cfg2.TargetLang = "C++";
cfg2.CppNamespace = 'namespace2'; % Namespace name
For more information on how to integrate multiple libraries generated by MATLAB Coder, refer the following MATLAB documentation.
Hope this is helpful.

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by