构建 MATLAB 的 C++ 库接口
clibgen
包要编译(发布)MATLAB 的 C++ 库接口,请参阅将 MATLAB 接口发布到 C++ 库的步骤。
有关从 MATLAB 调用库中函数的信息,请参阅使用预置的 MATLAB C++ 库接口。
函数
clibgen.generateLibraryDefinition | 为 C++ 库创建定义文件 |
clibgen.buildInterface | 在没有定义文件的情况下创建 C++ 库的接口 |
包
clibgen 包 | 支持从 MATLAB 调用 C++ 库功能的包和类的汇总 |
主题
如何发布接口
- What Types of Files Define Your Library?
How to set the arguments to theclibgen.generateLibraryDefinition
function. - 将 MATLAB 接口发布到 C++ 库的步骤
向 C++ 库发布接口的大纲。 - Requirements for Building Interface to C++ Libraries
Requirements for calling functions in external, compiled C++ libraries from MATLAB. - Distribute MATLAB Interface to C++ Library
How to share your MATLAB interface with MATLAB users.
由头文件和编译的库文件定义的库
- Windows 上的头文件和编译的库文件
此示例使用导入库文件
matrixOperations.lib
创建一个 C++ 库的 MATLAB 接口。- 步骤 1:
- 步骤 2: 定义缺失构造
- 步骤 3:
- 步骤 4:
- Linux 上的头文件和编译的库文件
此示例创建为带共享目标文件
libmwmatrixOperations.so
的 C++ 库创建 MATLAB 接口。- 步骤 1:
- 步骤 2: 定义缺失构造
- 步骤 3:
- 步骤 4:
- Header and C++ Compiled Library Files on macOS
This example creates a MATLAB interface to a C++ library with a dynamic shared library file
libmwmatrixOperations.dylib
.- 步骤 1:
- 步骤 2: 定义缺失构造
- 步骤 3:
- 步骤 4:
头文件/CPP 源文件定义的库
- 头文件和 CPP 源文件
此示例为在源文件
matrixOperations.hpp
和matrixOperations.cpp
中定义的 C++ 库创建一个 MATLAB 接口。- 步骤 1:
- 步骤 2: 定义缺失构造
- 步骤 3:
- 步骤 4:
- 只包含头文件的 HPP 文件
此示例通过头文件
school.hpp
中定义并创建了一个 C++ 库的 MATLAB 接口。- 步骤 1:
- 步骤 2:
- 步骤 3:
- 步骤 4:
定义和自定义
- Define MATLAB Interface for C++ Library
Generate and edit the MATLAB library definition file to customize and define the interface.
- Publish Help Text for MATLAB Interface to C++ Library
Provide documentation for end-users of a MATLAB interface to a C++ Library.
- C++ to MATLAB Data Type Mapping
Correspondence of MATLAB data types to C/C++ types. - Lifetime Management of C++ Objects in MATLAB
MATLAB rules for managing memory for C++ objects created in a MATLAB interface to a C++ compiled library. - Initialize Pointer Members of C++ Structures for MATLAB Interface to Library
Verify that C++ class constructors initialize pointer members.
疑难解答
Build C++ Library Interface and Review Contents
If library functionality is missing, the library might contain unsupported language features or data types.
C/C++ library features not supported in MATLAB.
Troubleshooting C++ Library Definition Issues
Information for resolving error when publishing a MATLAB interface to a C++ library.