Important: Please read the Qt Code of Conduct -

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

  • 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'"


    using namespace std;

    MainWindow::MainWindow(QWidget *parent) :

    QLabel *Image = new QLabel(this);
    QPixmap pixmap("C:/Users/Dipesh.Sharma/Documents/QT-Test/volansys.png");
    QSerialPort *ser = new QSerialPort(this);

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

  • Lifetime Qt Champion

    Hi @Dipesh-Sharma,

    please show your .pro file.


  • 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.


    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 +=

    HEADERS +=

    FORMS +=

    Default rules for deployment.

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

  • Moderators

    hi @Dipesh-Sharma
    when you take a look the the documentation

    You will see at the very top this box:


    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 😉

  • 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.

    Dipesh Sharma.

  • Lifetime Qt Champion


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

Log in to reply