Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Unresolved external symbol related to QSerialPort

    General and Desktop
    2
    3
    179
    Loading More Posts
    • 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
      russjohn834 last edited by

      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 Reply Quote 0
      • mranger90
        mranger90 last edited by

        Show your .pro file please.

        1 Reply Last reply Reply Quote 5
        • R
          russjohn834 last edited by

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

          1 Reply Last reply Reply Quote 2
          • First post
            Last post