Open BenjaminRodenberg opened 5 years ago
Some details on that from my side:
In the course of coupling a MATLAB solver with preCICE for my thesis, I am writing MATLAB bindings for precice based on the C++ MEX API introduced in R2018a. I do this in my fork. This works fine, but involves explicitly writing wrapper functions and classes for the preCICE functionalities. Hence, it is a lot of code that needs to be written and maintained.
R2019a (which was released less than a month ago) introduced the clibgen
package to import C++ libraries into MATLAB in a very comfortable way, more or less without writing any code. The process basically consists of two major steps:
clibgen.generateLibraryDefinition
to create a definition file from the library headers and <libname>.so
file. This file must then be manually reviewed to complete the information that can't be automatically determined by clibgen
.clibgen.build
on the definition file to import the library. This will create a folder containing a new <customName>.so
file. From then, functions and classes in there can be accessed as clib.<customName>.<libname>.*
.This process is really simple. Also, it makes the original bindings pretty much dispensable (for anyone with access to R2019a). However, as far as I figured it out up to now, there are a few shortcomings that must be dealt with, e.g.:
build
wants to know the buffer size for each pointer passed as function argument. This size must be computable from constants and input arguments. However, for vector data, the solver interface gets the problem dimension from its _dimension
property. This seems to be not supported in clibgen
as of now. Maybe this will be remedied in the future, or otherwise this must be worked around.These issues should be solved. Afterwards, clibgen
can replace the MATLAB binding.
In precice/precice#102 we want to implement/implemented a MATLAB API for preCICE. However, this API is based on functionality from MATLAB R2018b and before. R2019a introduces a more comfortable interface for the generation of a MATLAB interface to a C++ Library.