How do I expose the methods of my MATLAB object-oriented class through a C++ shared library with the MATLAB Compiler?
2 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2013 年 7 月 29 日
回答済み: Alan Frankel
2023 年 6 月 16 日
I have defined an object-oriented class in MATLAB using the CLASSDEF keyword and all other necessary MATLAB language object-oriented programming (OOP) constructs. Using the MATLAB Compiler, I would like to create a C++ dynamic-link library that exports a C++ class generated from my MATLAB class, and exposes its methods.
採用された回答
MathWorks Support Team
2016 年 6 月 24 日
The ability to directly generate a C++ class from a MATLAB class is currently not available as of MATLAB Compiler R2013a.
As a workaround, it is possible to write wrapper function MATLAB files around each of your MATLAB class methods and compile these into a C++ library. The wrapper functions should be written in such a way that:
1) If necessary, instances of your class are instantiated when the functions are invoked
2) The instances are made global such that methods may be invoked on the same class instance across calls to the MATLAB wrapper functions from C++.
Additionally, you may also write a C++ class whose methods wrap around the exported functions of the library in order to instantiate, invoke, and destroy your MATLAB class instances as necessary.
0 件のコメント
その他の回答 (1 件)
Alan Frankel
2023 年 6 月 16 日
As of R2023a, you can use the C++ MATLAB Data API Shared Library Support for Strongly Typed MATLAB Code. This is a feature of MATLAB Compiler SDK.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で C Shared Library Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!