Main Content

Distribute MATLAB Interface to C++ Library

Use this workflow to provide your MATLAB® users with the files and run-time dependency information so that they can call functions in your C++ library interface from their systems.

You can package the files into a toolbox installation (.mltbx) file. When the end-user runs the .mltbx file, MATLAB installs the interface and, if provided, library files and sets the MATLAB path. For more information, see Get and Manage Add-Ons.

To create the .mltbx file, follow these instructions in Create and Share Toolboxes to:

  • Select the Package Toolbox.

  • Set the toolbox folder to the folder that contains your interface file.

  • In the Toolbox Information field, choose a Toolbox Name. By default, the toolbox name is the name of the toolbox folder. The Toolbox Name becomes the .mltbx file name.

  • Provide Summary and Description text. For interface libname, identify the package name (calling syntax) as clib.libname.

  • Set the platform and release compatibility options in the Toolbox Portability field. Clear the MATLAB Online check box.

  • If your interface has third-party library dependencies, create a Getting Started Guide in the Examples, Apps, and Documentation field. For more information, see Interface Libraries with Library Dependencies.

Header Only Interface Libraries

If you built your interface from source code files only, then the only file you need to package is the interface file. The toolbox folder you specify in the Package Toolbox feature contains the interface file.

Interface Libraries with Library Dependencies

If you built your interface with shared library files, then you must provide the end-user with the dependent library files or instructions for installing the libraries from an external source.

If you built the interface using the Libraries name-value argument, put the shared library file in the folder with the interface file. This folder should be the toolbox folder you specify in Package Toolbox.

PlatformShared LibraryFile Extension

Microsoft® Windows®

Dynamic-link library file



Shared object file


Apple macOS

Dynamic shared library file


If your interface has run-time library dependencies, then create a Getting Started Guide in the Examples, Apps, and Documentation field. When you create the guide, MATLAB opens a live script named GettingStarted.mlx in a doc subfolder within your toolbox folder. Provide instructions for installing dependent library files that are available from an external source. These instructions must help the user satisfy run-time dependencies. Users of your interface can view the Getting Started Guide through the Options menu for the toolbox in the Add-On Manager.

Related Topics