Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unresolved external symbol related to QSerialPort
Forum Updated to NodeBB v4.3 + New Features

Unresolved external symbol related to QSerialPort

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 365 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    russjohn834
    wrote on last edited by
    #1

    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 error unresolved external symbol related to QSerialPort objects (build error screenshot attached)

    error_screenshot.JPG

    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!?

    1 Reply Last reply
    0
    • mranger90M Offline
      mranger90M Offline
      mranger90
      wrote on last edited by
      #2

      Show your .pro file please.

      1 Reply Last reply
      5
      • R Offline
        R Offline
        russjohn834
        wrote on last edited by
        #3

        @mranger90. Thanks a lot. I just realized I didnt include serialport in my pro file. Now it is building ok :)

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved