Unresolved external symbol related to QSerialPort
Solved
General and Desktop
-
Hi all,
I have a class file ,
tetra_grip_api
. I included this file with my project and I'm getting lots of linker tool errorunresolved external symbol
related toQSerialPort
objects (build error screenshot attached)tetra_grip_api.cpp
file is this:#include "tetra_grip_api.h" #include "tetra_grip_reporter.h" #include <QDebug> #include <stdio.h> #include <stdlib.h> #include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPortInfo> #define _CRT_SECURE_NO_DEPRECATE using namespace::std; tetra_grip_api::tetra_grip_api(QObject *parent) : QObject(parent) { } void tetra_grip_api::openSerialPort()//Vendor Identifier: 403 , Product Identifier: 6015 { serial = new QSerialPort(); QList <QSerialPortInfo>stim; QSerialPortInfo info; foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) { if(info.description() == "USB Serial Port" && info.manufacturer() == "FTDI" && QString::number(info.vendorIdentifier(), 16)== "403" && QString::number(info.productIdentifier(), 16)== "6015") { comPortName = info.portName(); } } serial->setPortName(comPortName); serial->setBaudRate(1000000); serial->setDataBits(QSerialPort::Data8); serial->setParity(QSerialPort::NoParity); serial->setStopBits(QSerialPort::OneStop); serial->setFlowControl(QSerialPort::HardwareControl); if(serial->open(QIODevice::ReadWrite)) { qDebug()<<"Open port OK"; } else { qDebug()<<"Failed to open port. Error code: "<< serial->error() << serial->errorString(); } } void tetra_grip_api::readData() { // const QByteArray data = api.serial->readAll(); // STIM_GUI_PROTOCOL_Process_Received_Bytes((uint8_t*)data.data(), (size_t)data.length()); } void tetra_grip_api::closeSerialPort() { if (serial->isOpen()) serial->close(); } void tetra_grip_reporter(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value) { //emit api.tetraGripEvent(topic, reg, value); }
and
tetra_grip_api.h
#ifndef TETRA_GRIP_API_H #define TETRA_GRIP_API_H #include <QObject> #include "Stim_includes/stim_gui_protocol.h" #include "Stim_includes/stim_gui_protocol_decode.h" #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string> #include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPortInfo> #include <QLabel> #include <QMessageBox> #include <QTimer> #define _CRT_SECURE_NO_DEPRECATE class tetra_grip_api : public QObject { Q_OBJECT public: explicit tetra_grip_api(QObject *parent = nullptr); QSerialPort *serial = nullptr; signals: void tetraGripEvent(STIM_GUI_TOPIC_T topic, uint8_t reg, uint32_t value); public slots: void openSerialPort(); void closeSerialPort(); void readData(); private: QString comPortName; }; //extern tetra_grip_api api; #endif // TETRA_GRIP_API_H
I include this in my other project class files..
Can you able to spot anything bad from this information!? -
@mranger90. Thanks a lot. I just realized I didnt include
serialport
in my pro file. Now it is building ok :)