Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Matlab in Qt
QtWS25 Last Chance

Matlab in Qt

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
9 Posts 3 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moeka_Chan
    wrote on last edited by
    #1

    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.

    Pablo J. RoginaP 1 Reply Last reply
    0
    • M Moeka_Chan

      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.

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @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

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Moeka_Chan
        wrote on last edited by Moeka_Chan
        #3

        @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.
        0_1549485898945_850f7ea9-26a9-4791-9ad9-810b709917c1-image.png
        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Do you mean the "engine.h" that you have added to your HEADERS variable ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Do you mean the "engine.h" that you have added to your HEADERS variable ?

            M Offline
            M Offline
            Moeka_Chan
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Are you sure of the paths of the files you are using ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              0
              • SGaistS SGaist

                Are you sure of the paths of the files you are using ?

                M Offline
                M Offline
                Moeka_Chan
                wrote on last edited by
                #7

                @SGaist
                LIBS and INCLUDEPATH should be correct in Qt.
                However, for the Visual Studio case, they may be correct. I change the directories in properties.....

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What do you change exactly ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  M 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    What do you change exactly ?

                    M Offline
                    M Offline
                    Moeka_Chan
                    wrote on last edited by
                    #9

                    @SGaist
                    I somehow solved the problem....
                    I run qmake.
                    Then, it manages to open the include file and run the codes, but it shows many warnings....
                    I don't know I must run qmake before run the codes...

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved