mlx tutorial: interfacing with c++

6 Ansichten (letzte 30 Tage)
Zohar
Zohar am 24 Jan. 2022
Kommentiert: Aniket am 28 Dez. 2022
I followed the 4-step tutorial (matlab 2019b):
A couple of parameters (ReturnCArrays, OverwriteExistingDefinitionFiles) weren't recognizable in clibgen.generateLibraryDefinition(), so I ran it without them.
summary(definematrixlib) and build(definematrixlib) ran fine. But step 4 didn't work:
Unable to resolve the name clib.matrixlib.Mat
and the doc and help matrixlib showed nothing.
---
The school example doesn't work either:
After adding this switch to build the library
I click the link to addpath, but 'help clib.school' returns
clib.school not found.
  2 Kommentare
Zohar
Zohar am 26 Jan. 2022
Let's start with some basic questions.
What are the final files that are needed to run a plugin?
Which file tells matlab about the interface and new class?
Is there a complete (final) example that comes with matlab?
Aniket
Aniket am 28 Dez. 2022
I recently followed the Matrix example on Matlab 2019b and it worked fine. The following step is necessary-
Put the compiled library file in the folder with the MATLAB® interface file. Uncomment and execute one of these statements based on your selected compiler.
%copyfile(fullfile(productPath,"win64","mingw64","*.dll"),".","f")
%copyfile(fullfile(productPath,"win64","microsoft","*.dll"),".","f")
Call addpath on the folder containing the interface file.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Zohar
Zohar am 1 Jun. 2022
Bearbeitet: Zohar am 1 Jun. 2022
In matlab 2021a it works fine.
When you run
matObj = clib.matrixlib.Mat
It looks for a file (in the path) "matrixlibInterface.dll" (which you need to build with the mlx steps), and it needs nothing beyond that.
Note that this file has a dependency on matrixOperations.dll, which needs to be in the path as well. Else, windows will give you the useless error of:
Unable to load interface library: 'matrixlibInterface.dll'. Reason: The
specified module could not be found.
Ensure the C++ dependent libraries for the interface library are added to run-time path.
which means the file couldn't be found or one of its dependencies is missing.
This C++ interface is pretty convenient compared to the C interface, where you need a .mex file per function.

Weitere Antworten (0)

Kategorien

Mehr zu Call C++ from MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by