Error : undefined reference to 'engOpen'



  • I'm trying to connect Matlab with QT. I'm using Qt Creator 4.2 and QT 5.8. This is what I have in my .pro file.

    QT       += core gui serialport axcontainer
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = Totem_app
    TEMPLATE = app
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    CONFIG+=c++11
    
    
    win32:CONFIG(release, debug|release): LIBS += -L'C:/Program Files/MATLAB/R2016b/extern/lib/win64/microsoft/' -llibmx
    else:win32:CONFIG(debug, debug|release): LIBS += -L'C:/Program Files/MATLAB/R2016b/extern/lib/win64/microsoft/' -llibmxd
    
    INCLUDEPATH += 'C:/Program Files/MATLAB/R2016b/extern/lib/win64/microsoft'
    DEPENDPATH += 'C:/Program Files/MATLAB/R2016b/extern/lib/win64/microsoft'
    

    I have also include the head file.

    #include <QFileDialog>
    #include <QtPlugin>
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QThread>
    #include <QTextCodec>
    #include "C:\Program Files\MATLAB\R2016b\extern\include\engine.h"
    

    Could somebody help me with this problem? How could I include engine.h without providing the whole path directory? What am I doing wrong that I'm getting the undefined reference error? All help is highly appreciated it.



  • How could I include engine.h without providing the whole path directory?

    it should be

    INCLUDEPATH += 'C:/Program Files/MATLAB/R2016b/extern/include'
    DEPENDPATH += 'C:/Program Files/MATLAB/R2016b/extern/include'
    

    and your include just be #include <engine.h>
    but this does not solve your problem, I don't have matlab so i can't test it, can you post the contents of C:/Program Files/MATLAB/R2016b/extern/lib/win64/microsoft/

    What compiler are you using (including architecture 32/64 bit)?



  • @VRonin Thank you so much for your help. This is what I have in the folder
    alt text

    This is my qt version
    alt text

    The compiler that I'm using is MinGW 32 bit. Is there more information that I should provide? Is it possible to do this on QT creator?



  • @anfedres said in Error : undefined reference to 'engOpen':

    The compiler that I'm using is MinGW 32 bit

    lib/win64/microsoft

    You can't mix and match compilers. You are trying to use MSVC?? 64 bit libraries with MinGW at 32 bit

    Either you install the same version of Visual Studio those libraries were built in or you search for those of your compiler: C:/Program Files/MATLAB/R2016b/extern/lib/win32/gcc maybe?

    Once you found them you also have to find out what library engOpen is in. currently you are linking only libmx. Given one of the libraries is called libeng I'd go with that one if I had to bet

    P.S.

    This is my qt version

    No, that's your Qt Creator Version, to see the Qt Version you have to look here:
    Qt Version



  • @VRonin But I'm not using Visual Studio. Is it possible to install another compiler for QT?



  • @VRonin I understand now. I'm trying to link libraries for MSVC, instead. I should be using libraries for MinGW.



  • But I'm not using Visual Studio. Is it possible to install another compiler for QT?

    The only way to install MSVC before MSVC2015 is installing Visual Studio that's why I mentioned it. once you have the compiler you can use whatever IDE you prefer (like Qt Creator). You can use the build tools without installing Visual Studio for MSVC2015 but the first thing you have to find out is what version those libraries were built with

    A way to do it is using dependency walker: http://www.dependencywalker.com/ open the library if one of the dependencies is contains MSVCP14 then it's MSVC2015, if it contains MSVCP12 then it's MSVC2013



  • It seems that I will have to install something else. Or use a different approach. How about Qprocess? It won't work the same. But my goal is call a program that I have done in Matlab and run it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.