Hauptinhalt

clibPublishInterfaceWorkflow

R2026b

Create live script to publish platform-specific interface for C/C++ library

Since R2023a

    Description

    If you have a C or C++ shared library that exports functionality that can be called from another application, then you can use those classes and functions directly in MATLAB®. To get started, you must first build an interface to the library to use to call the functionality in MATLAB. Someone who creates this interface is called a publisher. You can package the interface and share it with a MATLAB end user. For information about calling these C/C++ functions from MATLAB, see Use Prebuilt MATLAB Interface to C/C++ Library.

    clibPublishInterfaceWorkflow creates a template live script that you can use as a starting point to publish a MATLAB interface to a C/C++ library. The generated script can be modified or reused to support automated or iterative interface definition workflows. Use this script to:

    1. Generate the interface definition object, for example, using the Generate C++ Interface task.

    2. Define missing functionality by updating the interface definition object in the script.

    3. Build the MATLAB interface to the C/C++ library file from the interface definition.

    4. Test the interface by setting up run-time libraries and calling library functions.

    Use clibPublishInterfaceWorkflow to publish an interface for your current platform. To support multiple platforms, reuse or adapt the generated script for each platform by running the published script on the specific platform.

    For more information, see How to Publish a MATLAB Interface to a C/C++ Library.

    example

    Examples

    collapse all

    Identify the C++ files that define your library.

    Call the clibPublishInterfaceWorkflow function in the MATLAB Command Window to create the live script.

    clibPublishInterfaceWorkflow

    In the dialog box that appears, specify a file name and location to save the live script. Then, follow the instructions in each section of the script to generate, define, build, and test the library interface. For example, see Publish Platform-Independent MATLAB Interface.

    Alternative Functionality

    Publish at Command Line

    You can also create and customize interface definitions programmatically without using a live script.

    Version History

    Introduced in R2023a

    expand all

    R2026b: Create Interface from clibgen.api.InterfaceDefinition object