构建 MATLAB 的 C++ 库接口
clibgen
命名空间要编译(发布)MATLAB 的 C++ 库接口,请调用clibPublishInterfaceWorkflow
。有关概述,请参阅发布 C++ 库 MATLAB 接口的步骤。
有关从 MATLAB 调用库中函数的信息,请参阅使用预置的 MATLAB C++ 库接口。
函数
clibPublishInterfaceWorkflow | Publish interface for C++ library in the Live Editor (自 R2023a 起) |
clibgen.generateLibraryDefinition | 为 C++ 库创建定义文件 |
clibgen.buildInterface | 在没有定义文件的情况下创建 C++ 库的接口 |
实时编辑器任务
生成 C++ 接口 | Generate definition file for C++ interface library in the Live Editor (自 R2023a 起) |
命名空间
clibgen Namespace | 支持从 MATLAB 调用 C++ 库功能的命名空间和类的摘要 |
主题
如何发布接口
- What Types of Files Define Your Library?
How to set the arguments to theclibgen.generateLibraryDefinition
function. - 发布 C++ 库 MATLAB 接口的步骤
发布 C++ 库接口的大纲。 - Requirements for Building Interface to C++ Libraries
Requirements for calling functions in external, compiled C++ libraries from MATLAB.
发布由这些文件定义的库的接口
- Windows 上的头文件和 C++ 编译的库文件
此示例使用导入库文件matrixOperations.lib
创建一个 C++ 库的 MATLAB 接口。 - Linux 上的头文件和 C++ 编译的库文件
此示例创建为带共享目标文件libmwmatrixOperations.so
的 C++ 库创建 MATLAB 接口。 - macOS 上的头文件和 C++ 编译的库文件
此示例创建为带动态共享库文件libmwmatrixOperations.dylib
的 C++ 库创建 MATLAB 接口。 - 头文件和 C++ 源文件
此示例为在源文件matrixOperations.hpp
和matrixOperations.cpp
中定义的 C++ 库创建一个 MATLAB 接口。 - 只包含头文件的 HPP 文件
此示例通过头文件school.hpp
中定义并创建了一个 C++ 库的 MATLAB 接口。
定义和自定义
- 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.
共享您的接口
- Distribute MATLAB Interface to C++ Library
How to share your MATLAB interface with MATLAB users.
- 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 errors when publishing a MATLAB interface to a C++ library.
- Resolve Build Error: Multiple Redefinition Linker Errors
- Resolve Build Error: Unresolved External Symbols
- Build Error Due to Compile-Time Checks
- Errors Parsing Header Files on macOS
Debug C++ Library from MATLAB Interface
How to build a debug version of a MATLAB interface to a C++ library.