错误:在Qt中对'engOpen'的未定义引用

时间:2017-03-23 17:25:32

标签: c++ matlab qt

我尝试过以下post中所述的内容。但我仍然有错误

我正在尝试将Matlab与QT连接。我正在使用Qt Creator 4.2和QT 5.8。这就是我在.pro文件中的内容。

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'

我还包括头文件。

#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"

有人可以帮我解决这个问题吗?如何在不提供整个路径目录的情况下包含engine.h?我得到了未定义的引用错误,我做错了什么?所有帮助都非常感谢。

1 个答案:

答案 0 :(得分:0)

要在没有整个路径的情况下包含engine.h,请添加另一个包含路径,如下所示:
INCLUDEPATH += 'C:/Program Files/MATLAB/R2016b/extern/include/'

未链接的引用,如您链接的帖子中所述,意味着您缺少一个语句,该语句指定需要链接的库。

来自here我看到,虽然您已列出libmx,但您还需要添加libeng