Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Facing error "undefined reference to __imp__ZN......."
Forum Updated to NodeBB v4.3 + New Features

Facing error "undefined reference to __imp__ZN......."

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 4 Posters 10.3k 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.
  • D Offline
    D Offline
    Dipesh Sharma
    wrote on last edited by
    #1

    Hello,
    I am new to QT and i am trying to configure the serial port for sending and receiving data.
    But while i configure the serial port i am facing below mentioned error.
    I am using QT creator and c++ for writing code.

    "C:\Users\Dipesh.Sharma\Documents\QT-Test\mainwindow.cpp:32: error: undefined reference to `__imp__ZN11QSerialPortC1EP7QObject'"

    #include<QtSerialPort/QSerialPort>
    #include<QtSerialPort/QSerialPortInfo>

    using namespace std;

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
    {

    QLabel *Image = new QLabel(this);
    QPixmap pixmap("C:/Users/Dipesh.Sharma/Documents/QT-Test/volansys.png");
    Image->setPixmap(pixmap);
    Image->setGeometry(150,-200,500,500);
    Image->show();
    
    QSerialPort *ser = new QSerialPort(this);
    ser->setParity(QSerialPort::NoParity);
    

    kindly help me in this issue if any of the more inputs are required please let know.

    aha_1980A 1 Reply Last reply
    1
    • D Dipesh Sharma

      Hello,
      I am new to QT and i am trying to configure the serial port for sending and receiving data.
      But while i configure the serial port i am facing below mentioned error.
      I am using QT creator and c++ for writing code.

      "C:\Users\Dipesh.Sharma\Documents\QT-Test\mainwindow.cpp:32: error: undefined reference to `__imp__ZN11QSerialPortC1EP7QObject'"

      #include<QtSerialPort/QSerialPort>
      #include<QtSerialPort/QSerialPortInfo>

      using namespace std;

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent)
      {

      QLabel *Image = new QLabel(this);
      QPixmap pixmap("C:/Users/Dipesh.Sharma/Documents/QT-Test/volansys.png");
      Image->setPixmap(pixmap);
      Image->setGeometry(150,-200,500,500);
      Image->show();
      
      QSerialPort *ser = new QSerialPort(this);
      ser->setParity(QSerialPort::NoParity);
      

      kindly help me in this issue if any of the more inputs are required please let know.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @Dipesh-Sharma,

      please show your .pro file.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        Dipesh Sharma
        wrote on last edited by
        #3

        Hello aha,

        kindly find the .pro file

        #-------------------------------------------------

        Project created by QtCreator 2019-07-01T11:38:28

        #-------------------------------------------------

        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = QT-Test
        TEMPLATE = app

        The following define makes your compiler emit warnings if you use

        any feature of Qt which has been marked as deprecated (the exact warnings

        depend on your compiler). Please consult the documentation of the

        deprecated API in order to know how to port your code away from it.

        DEFINES += QT_DEPRECATED_WARNINGS

        You can also make your code fail to compile if you use deprecated APIs.

        In order to do so, uncomment the following line.

        You can also select to disable deprecated APIs only up to a certain version of Qt.

        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

        CONFIG += c++11

        SOURCES +=
        main.cpp
        mainwindow.cpp

        HEADERS +=
        mainwindow.h

        FORMS +=
        mainwindow.ui

        Default rules for deployment.

        qnx: target.path = /tmp/$${TARGET}/bin
        else: unix:!android: target.path = /opt/$${TARGET}/bin
        !isEmpty(target.path): INSTALLS += target

        J.HilkJ 1 Reply Last reply
        1
        • D Dipesh Sharma

          Hello aha,

          kindly find the .pro file

          #-------------------------------------------------

          Project created by QtCreator 2019-07-01T11:38:28

          #-------------------------------------------------

          QT += core gui

          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

          TARGET = QT-Test
          TEMPLATE = app

          The following define makes your compiler emit warnings if you use

          any feature of Qt which has been marked as deprecated (the exact warnings

          depend on your compiler). Please consult the documentation of the

          deprecated API in order to know how to port your code away from it.

          DEFINES += QT_DEPRECATED_WARNINGS

          You can also make your code fail to compile if you use deprecated APIs.

          In order to do so, uncomment the following line.

          You can also select to disable deprecated APIs only up to a certain version of Qt.

          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

          CONFIG += c++11

          SOURCES +=
          main.cpp
          mainwindow.cpp

          HEADERS +=
          mainwindow.h

          FORMS +=
          mainwindow.ui

          Default rules for deployment.

          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          hi @Dipesh-Sharma
          when you take a look the the documentation
          https://doc.qt.io/qt-5/qserialport.html

          You will see at the very top this box:

          0_1562133329135_8fc48a0f-0a6d-4ccc-876c-0a8b1f241031-image.png

          It tell's you, that you need to add the serialport module to your project file QT += serialport it is missing in your pro file.

          Add it, clean -> run qmake -> build and the error should go away.

          Remember every time you make changes in your pro file you should explicitly rerun qmake! It's not needed 100% of the time, but getting into the habit will save you time in the long run 😉


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          5
          • D Offline
            D Offline
            Dipesh Sharma
            wrote on last edited by
            #5

            Hi @aha_1980

            Actually i debug around and came to know serialport widget need to be added in the .pro file.

            It resolved my issue.

            Thanks for your help.

            Regards,
            Dipesh Sharma.

            aha_1980A 1 Reply Last reply
            2
            • D Dipesh Sharma

              Hi @aha_1980

              Actually i debug around and came to know serialport widget need to be added in the .pro file.

              It resolved my issue.

              Thanks for your help.

              Regards,
              Dipesh Sharma.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Dipesh-Sharma

              Glad you figured it out. So please mark this topic as SOLVED. Thanks!

              Qt has to stay free or it will die.

              1 Reply Last reply
              1
              • Y Offline
                Y Offline
                yang_ding
                wrote on last edited by
                #7

                I met the same question. Adding "QT += serialport" into the .pro file can solve it.

                1 Reply Last reply
                0

                • Login

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