简体   繁体   English

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

[英]Error : undefined reference to 'engOpen' in Qt

I have tried to the following that says in this post . 我已经尝试过以下内容,在这篇文章中 But I'm still having the error 但是我仍然有错误

I'm trying to connect Matlab with QT. 我正在尝试将Matlab与QT连接起来。 I'm using Qt Creator 4.2 and QT 5.8. 我正在使用Qt Creator 4.2和QT 5.8。 This is what I have in my .pro file. 这就是我的.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'

I have also included 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? 如何在不提供整个路径目录的情况下包含engine.h? What am I doing wrong that I'm getting the undefined reference error? 我收到未定义的参考错误,这是我做错了什么? All help is highly appreciated it. 非常感谢所有帮助。

To include engine.h without the whole path, add another include path like this: engine.h不包含整个路径的情况下包含engine.h ,请添加另一个包含路径,如下所示:
INCLUDEPATH += 'C:/Program Files/MATLAB/R2016b/extern/include/'

The undefined reference, as explained in the post you linked, means you are missing a statement which specifies which library needs to be linked. 如链接文章中所述,未定义的引用表示您缺少指定要链接哪个库的语句。

From here I see that, although you have libmx already listed, you need to add libeng too. 这里我看到,尽管您已经列出了libmx ,但是您也需要添加libeng

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM