Distribute MATLAB Interface to C++ Library - MATLAB & Simulink (original) (raw)

Main Content

What Your MATLAB User Needs

To call functions in your C++ library interface from their MATLAB® program, your users need:

Interface files and compiled library files have these platform-specific file extensions.

Platform Shared Library File Extension
Microsoft® Windows® Dynamic-link library file .dll
Linux® Shared object file .so
Apple macOS Dynamic shared library file .dylib

To determine if your library libname has run-time library dependencies, run these platform-specific commands from the operating system prompt.

dumpbin /dependents libname.dll  

Share Your Interface Files

If your MATLAB users have direct access to your files, such as through a shared network location, then run the Set up and copy run-time libraries section of the clibPublishInterfaceWorkflow script to call the copyRuntimeDependencies function. Your users access the interface from this location.

Alternatively, create a MATLAB add-on. For information, see Distribute Your Interface as an Add-On.

Distribute Your Interface as an Add-On

Use this workflow to provide your MATLAB users with the files and run-time dependency information by packaging 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:

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.

If you built the interface using the Libraries name-value argument, then follow the steps in Share Your Interface Files using the folder with the interface file. This folder should be the toolbox folder you specify inPackage Toolbox.

If your interface has run-time library dependencies and you can distribute them, then follow the steps in Share Your Interface Files using theadditionalRuntimeDependencies oradditionalRuntimeFolders options for thecopyRuntimeDependencies function.

If you do not have permission to distribute the run-time libraries, 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. For more information, see Manage Add-Ons and Call Functions in C++ Compiled Library.

See Also

Topics