Main Content

build

Class: clibgen.LibraryDefinition
Package: clibgen

Build library interface

Syntax

build(libDef)

Description

build(libDef) validates and builds an interface from the library definition file created with the clibgen.generateLibraryDefinition function. For more information, see Steps to Publish a MATLAB Interface to a C++ Library.

If successful, the method prints an output to the Command Window. The output contains information about the interface file that is generated and any functions dropped because of validation failure.

Examples

expand all

Create a header file sample.hpp with these statements.

void func1(){}; 
void func2 (int){}; 
double func3(int){}; 

Generate the definition file.

clibgen.generateLibraryDefinition("sample.hpp")
Using MinGW64 Compiler (C++) compiler.
Generated definition file definesample.mlx and data file 'sampleData.xml' contain 
definitions for 3 constructs supported by MATLAB.
Build using build(definesample).

The definition file completely defines the interface.

View the contents.

summary(definesample)
MATLAB Interface to sample Library

Functions
clib.sample.func1()
clib.sample.func2(int32)
double clib.sample.func3(int32)

Build the interface.

build(definesample)
Building interface file 'sampleInterface.dll'.
Interface file 'sampleInterface.dll' built in folder 'C:\Documents\MATLAB\sample'.
To use the library, add the interface file folder to the MATLAB path.

Input Arguments

expand all

Library definition, specified as a clibgen.LibraryDefinition object. libDef is the file created by clibgen.generateLibraryDefinition.

Example: build(defineschool)

Tips

Alternative Functionality

clibgen.buildInterface Function

Use the clibgen.buildInterface function instead of clibgen.generateLibraryDefinition and build if you know that MATLAB® automatically defines all class constructors, methods, data members, and functions for the library, or if undefined constructs are not required by your interface.

For more information, see Build C++ Library Interface and Review Contents.

Introduced in R2019a