Contenu principal

build

R2026b

Class: clibgen.LibraryDefinition
Namespace: clibgen

(Not recommended) Build library interface

clibgen.LibraryDefinition.build is not recommended. To build a MATLAB® interface to a C/C++ library, create a clibgen.api.InterfaceConfiguration object. For more information on updating your code, see Version History.

Syntax

build(libDef)

Description

build(libDef) validates and builds an interface from the library definition file created with the clibgen.generateLibraryDefinition function.

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. The function also displays the build log if the Verbose name-value argument in clibgen.generateLibraryDefinition is true.

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",OverwriteExistingDefinitionFiles=true)
C++ compiler set to 'MinGW64 Compiler (C++)'.
Definition file definesample.m contains definitions for 3 constructs supported by MATLAB.
- 3 construct(s) are fully defined.
To build the interface, call 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' for clib interface 'sample'.
Interface file 'sampleInterface.dll' built in folder 'C:\Documents\MATLAB\sample'.

To use the library, add the interface file folder to the MATLAB path.
addpath('C:\Documents\MATLAB\sample')

Input Arguments

expand all

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

Example: build(defineschool)

Version History

Introduced in R2019a

expand all