mlx tutorial: interfacing with c++

조회 수: 6 (최근 30일)
Zohar
Zohar 2022년 1월 24일
댓글: Aniket 2022년 12월 28일
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
Zohar
Zohar 2022년 1월 26일
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 2022년 12월 28일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Zohar
Zohar 2022년 6월 1일
편집: Zohar 2022년 6월 1일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by