我已經看到了幾個問題並搜索了很多,我找不到使用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'的二進制文件。 –