Problem with Matlab API Data in c++ project (QtCreator)
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I am having trouble trying to configure a project in qt creator (version 4.15.1 and 6.2.1 qt framework with MSVC 2019 64 bit compiler) using the matlab api C++. I have compiled a shared library using the Library compiler SDK from Matlab (R2021b). I also have previously succesfully configure the project to use the old version (Matlab API C), using mxarrays and mcl and mlx functions. The project works fine at this point.
I want to upgrade the code to use the modern version of the API for c++, because of some of its features (for example, using asynchronous calls to the library function).
I have added the following lines to my project file (qmake):
# MATLAB API
MATLAB_FOLDER = $$(MATLAB_RUNTIME_FOLDER)
LIBS += -L$$MATLAB_FOLDER/extern/lib/win64/microsoft -llibMatlabCppSharedLib -llibMatlabDataArray
INCLUDEPATH += $$MATLAB_FOLDER/extern/include
DEPENDPATH += $$MATLAB_FOLDER/extern/include
MATLAB_RUNTIME_FOLDER is a system variable where i indicate the path to the matlab runtime folder (version 9.11). I also copied the dlls into my project where the .exe is created. From /v911/runtime/win64 i took libMatlabCppSharedLib9_11.dll and from /v911/extern/bin/win64 libMatlabDataArray.dll.
The initialization of the aplication and the library seems to work fine:
namespace mc = matlab::cpplib;
namespace md = matlab::data;
std::vector<std::u16string> options = { u"-nojvm" };
auto matlab_application = mc::initMATLABApplication(mc::MATLABApplicationMode::IN_PROCESS, options);
auto lib = mc::initMATLABLibrary(matlab_application, u"test.ctf");
The problem lies when I try to declare a factory variable:
md::ArrayFactory factory;
My application launches an exception and i do not know why. Maybe I lack another dependancy ?
댓글 수: 2
답변 (1개)
Divyanshu
2024년 1월 31일
편집: Divyanshu
2024년 1월 31일
Hi Cristian,
Please go through the following pointers:
- Ensure that the file 'C:\Program Files\MATLAB\MATLAB Runtime\v911\runtime\win64' is added to the path.
- Launch MATLAB in your system.
- Now build the application with the following command:
>>mbuild main.cpp
- Execute the application using the command:
!main.exe
Regards,
Divyanshu
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Deploy to C++ Applications Using MATLAB Data API (C++11)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!