mlx tutorial: interfacing with c++

13 visualizzazioni (ultimi 30 giorni)
Zohar
Zohar il 24 Gen 2022
Commentato: Aniket il 28 Dic 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 Commenti
Zohar
Zohar il 26 Gen 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 il 28 Dic 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.

Accedi per commentare.

Risposta accettata

Zohar
Zohar il 1 Giu 2022
Modificato: Zohar il 1 Giu 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.

Più risposte (0)

Tag

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by