BuildMATLABInterface to C++ Library
clibgen
packageTo build (publish) a MATLAB interface to a C++ library, seeSteps to Publish a MATLAB Interface to a C++ Library.
For information about calling functions in the library from MATLAB, seeUse Prebuilt MATLAB Interface to C++ Library.
Functions
clibgen.generateLibraryDefinition |
Create definition file for C++ library |
clibgen.buildInterface |
Create interface to C++ library without definition file |
Packages
clibgen Package |
Summary of packages and classes to support calling C++ library functionality fromMATLAB |
Topics
How To Publish an Interface
- What Types of Files Define Your Library?
How to set the arguments to theclibgen.generateLibraryDefinition
function. - Steps to Publish a MATLAB Interface to a C++ Library
Outline for publishing an interface to a C++ library. - Requirements for Building Interface to C++ Libraries
Requirements for calling functions in external, shared C++ libraries from MATLAB. - Distribute MATLAB Interface to C++ Library
How to share your MATLAB interface with MATLAB users.
特定于平台的库文件的例子
- Header File and Import Library File on Windows
This example creates a MATLAB interface to a C++ library with an import library file
matrixOperations.lib
.- STEP 1:Generate Interface on Windows
- STEP 2:Define Missing Constructs
- STEP 3:Build Interface
- STEP 4:Call Library Functions on Windows
- Header File and Shared Object File on Linux
This example creates a MATLAB interface to a C++ library with a shared object file
libmwmatrixOperations.so
.- STEP 1:Generate Interface on Linux
- STEP 2:Define Missing Constructs
- STEP 3:Build Interface
- STEP 4:Call Library Functions on Linux
- Header File and Dynamic Shared Library File on macOS
This example creates a MATLAB interface to a C++ library with a dynamic shared library file
libmwmatrixOperations.dylib
.- STEP 1:Generate Interface on macOS
- STEP 2:Define Missing Constructs
- STEP 3:Build Interface
- STEP 4:Call Library Functions on macOS
Examples for Libraries Defined by Header/CPP Source Files
- Header and CPP Source Files
This example creates a MATLAB interface to a C++ library defined in source files
matrixOperations.hpp
andmatrixOperations.cpp
. - Header-Only HPP File
This example creates a MATLAB interface to a C++ library defined in a header file
school.hpp
.
Define and Customize
- Define MATLAB Interface for C++ Library
Generate and edit the MATLAB
MLX
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++ shared library. - Initialize Pointer Members of C++ Structures for MATLAB Interface to Library
Verify that C++ class constructors initialize pointer members.
Troubleshooting
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.