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. Need help in solving the undefined reference error for qt5
QtWS25 Last Chance

Need help in solving the undefined reference error for qt5

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 2.6k 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    Hi All
    I am trying to run a code with the QT5 library
    I have the following code

    #include <QtWidgets/QWidget>
    2 #include <QtWidgets/QApplication>
    3 #include <QtWidgets/QPushButton>
    4 int main(int argc, char *argv[])
    5 {
    6 QApplication app(argc, argv);
    7
    8 QPushButton hello("Hello world!");
    9 hello.resize(100, 30);
    10
    11 hello.show();
    12 return app.exec();
    13 }
    ~
    I have a following .pro file and

    ######################################################################

    Automatically generated by qmake (3.1) Thu Oct 11 10:04:00 2018

    ######################################################################

    TEMPLATE = app
    TARGET = Qt_Examples
    INCLUDEPATH += .
    QT += core gui
    @QT += widgets@

    The following define makes your compiler warn you 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
    following is .pro file

    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

    Input

    SOURCES += main.cpp
    ~

    I am getting following e

    undefined reference to QWidget::show()' main.o:(.qtversion[qt_version_tag]+0x0): undefined reference to qt_version_tag'
    main.o: In function QTypedArrayData<unsigned short>::deallocate(QArrayData*)': qt594_20180627/debug/linux_x86_64/include/QtCore/qarraydata.h:237: undefined reference to QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)'
    collect2: error: ld returned 1 exit status

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If you make a empty default GUI project , does that run ?
      How did you install Qt5 ?

      Q 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @mrjj, did you re-run qmake after adding QT += widgets to your .pro file ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply
        2
        • mrjjM mrjj

          Hi
          If you make a empty default GUI project , does that run ?
          How did you install Qt5 ?

          Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          @mrjj

          What is empty default project can u please elaborate

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            To add to @mrjj, did you re-run qmake after adding QT += widgets to your .pro file ?

            Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #5

            @SGaist

            Yes I did . Any hints to solve the problem

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Hi, perhaps there's a problem because this is not a Qt5 program, it's at least [10 years old example](https://doc.qt.io/archives/4.3/tutorial-t1.html

              You could try what @mrjj suggests: start Qt Creator, select File, New File or Project, select Application, select Qt Widgets Application, don't change anything, just try to run it.

              1 Reply Last reply
              3
              • Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #7

                I am running in linux and do not have a Qt Creator. COuld you generate a code for me for Empty Gui Project that I can resue in QMake in linux

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #8

                  I am also running Linux but I have Qt Creator, makes it easier to use Qt. You can download it for free here

                  1 Reply Last reply
                  1
                  • Q Offline
                    Q Offline
                    Qt Enthusiast
                    wrote on last edited by
                    #9

                    which version of Qt creator is compatible with Qt5

                    1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by hskoglund
                      #10

                      I have 4.7.1 and it works fine.
                      0_1539296832925_Screenshot from 2018-10-12 00-26-32.png

                      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