我已经看到了几个问题并搜索了很多,我找不到使用qextserialport声明串行端口对象的方法,以便读写arduino。我试了一下,用户在How to write on serial port using Qextserialport做,但是编译器给了我以下错误:无法使用qextserialport声明串行端口
undefined reference to `QextSerialPort::QextSerialPort(QString const&, QextSerialPort::QueryMode, QObject*)'
这里是代码我使用:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtExtSerialPort/qextserialport.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_BTN_Connect_clicked()
{
int index=ui->Selector_Port->currentIndex();
QextSerialPort *port = new QextSerialPort("/dev/ttyACM0");
}
为什么会出现这种错误出现在哪里?我使用Debian 8.2和QT 4.8.6
编辑:,我有以下错误
CONFIG += qesp_linux_udev
QT += extserialport
到项目文件:
"Project MESSAGE: Warning: unknown QT: extserialport"
添加行后
你的'.pro'文件中是否有'QT + = extserialport'行?你是否将它用作Qt模块或直接在'中包含项目。pro' include(qextserialport/src/qextserialport.pri)? –
是的,这一行在项目文件中,但它不起作用。 – Charlie
这是一个链接器错误。这意味着它无法找到执行'QextSerialPort'的二进制文件。 –