Main Content

Build MATLAB Interface to C/C++ Library

R2026b
Programmatically create a MATLAB® interface to a C or C++ library

You can build (publish) a MATLAB interface to a C or C++ library using MATLAB code that you maintain. Specify the headers and symbols to include, adjust only the definitions MATLAB cannot infer, and rebuild the interface consistently across platforms and library updates. For an overview, see How to Publish a MATLAB Interface to a C/C++ Library.

Alternatively, call clibPublishInterfaceWorkflow for guided steps that create a platform-specific interface.

For information about calling functions in the library from MATLAB, see Use Prebuilt MATLAB Interface to C/C++ Library.

Before R2026b: Your options to publish an interface are to call clibPublishInterfaceWorkflow to use a workflow script or to create a definition file for the library using clibgen.generateLibraryDefinition. For more information, see How to Publish a MATLAB Interface to a C/C++ Library (R2026a).

Classes

clibgen.api.InterfaceConfiguration Specify configuration for generating MATLAB interface to C/C++ library (Since R2026b)
clibgen.api.InterfaceDefinitionInspect, customize, and build MATLAB interface definition for C/C++ library (Since R2026b)

Functions

clibPublishInterfaceWorkflowCreate live script to publish platform-specific interface for C/C++ library (Since R2023a)
clibgen.generateLibraryDefinition(Not recommended) Create definition file for C/C++ library
clibgen.buildInterface(Not recommended) Create interface to C/C++ library without definition file

Live Editor Tasks

Generate C++ InterfaceConfigure and generate MATLAB interface to C/C++ library (Since R2023a)

Namespaces

clibgen.apiSummary of programmatic workflow objects for publishing MATLAB interface to C/C++ library (Since R2026b)
clibgen(Not recommended. Instead use objects in the clibgen.api namespace.) Classes to publish MATLAB interface to C++ library using the clibgen.generateLibraryDefinition function

Topics

Define and Customize

Share Your Interface

Troubleshooting

Build C/C++ Library Interface and Review Contents

When you build a MATLAB interface to a C/C++ library, you can review the contents of the generated interface.

Limitations to C/C++ Support

C/C++ library features not supported in MATLAB.

Troubleshooting C/C++ Library Definition Issues

Information for resolving errors when publishing a MATLAB interface to a C/C++ library.

Troubleshooting MATLAB Interface to C/C++ Library Run-Time Issues

Resolve unexpected run-time errors when calling functions in a published MATLAB interface to a C/C++ compiled library.

Troubleshooting Calls to C/C++ Library Functions

Resolve unexpected issues when calling functions in a C/C++ compiled library.

Debug C++ Library from MATLAB Interface

How to build a debug version of a MATLAB interface to a C++ library.