How can I avoid conflicting function names in two different static libs. when using MATLAB Coder?
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Infinite_king
2023-12-1
编辑:Infinite_king
2023-12-1
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!