Matlab in Qt
-
Hello,
I am going to use Matlab function in Qt.
I search for a long time and don't get anything...
I am trying Matlab engine API in C++, but Qt cannot find engine.h.
In the current documentation of Matlab, it seems to use other headers.
Most posts about this topic are old. -
@Moeka_Chan could it be possible you post what you have done so far?
i.e. your .pro file, some code snippets, compiler/runtime errors -
@Pablo-J-Rogina
I modified my project file according to this post. https://forum.qt.io/topic/85112/configure-matlab-engine-in-qtcreator/14
I created a default UI project, only modified the .pro file and add the "engine.h" header.
The Manage Kits is shown in the figure.
The .pro file is shown below.QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = QtUIMatlabTest TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS CONFIG += c++11 CONFIG += create_prl CONFIG += link_prl SOURCES += \ main.cpp \ mainwindow.cpp FORMS += \ mainwindow.ui HEADERS += mainwindow.h \ engine.h LIBS += -L"C:/Program Files/MATLAB/R2017b/extern/lib/win64/microsoft/" -llibeng \ -L"C:/Program Files/MATLAB/R2017b/extern/lib/win64/microsoft/" -llibmx INCLUDEPATH += "C:/Program Files/MATLAB/R2017b/extern/include" qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
I got an error.
error: C1083: Cannot open include file: 'engine.h': No such file or directory
I tried other headers and modified the .pro file, following the link: https://www.mathworks.com/help/matlab/matlab_external/build-c-engine-programs.html.
I got error: C1083 again. -
Hi,
Do you mean the "engine.h" that you have added to your
HEADERS
variable ? -
@SGaist
Yes. I also tried MatlabEngine.hpp after changing the library. It said that Cannot open include file 'MatlabEngine.hpp'.Since I failed to make it in Qt, I tried to use Matlab in C++ in Visual Studio (not Qt Creator). The debug failed because libMatlabEngine.dll was not found.
-
Are you sure of the paths of the files you are using ?
-
What do you change exactly ?