フィルターのクリア

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

7 ビュー (過去 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?

回答 (1 件)

Infinite_king
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.

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by