Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Undefined reference to `QApplication::QApplication(int&, char**, int)
QtWS25 Last Chance

Undefined reference to `QApplication::QApplication(int&, char**, int)

Scheduled Pinned Locked Moved Installation and Deployment
11 Posts 4 Posters 26.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.
  • E Offline
    E Offline
    e.ustimenko
    wrote on last edited by
    #1

    Hello everyone. My name is Evgeny.
    I have the same problem: undefined reference to `QApplication::QApplication(int&, char**, int), and more than.
    I have read some forums, but don't understand something.
    What I should do in Qt-SDK to solve this problem?

    Thanks a lot.

    OS: Linux Debian
    QT-version: 4.7.1

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maciej
      wrote on last edited by
      #2

      Hi Evgeny,

      Could you post code which is causing problems?

      Earth is a beta site.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        anselmolsm
        wrote on last edited by
        #3

        The error says you're trying to use a QApplication constructor that does not exist. Probably there is an error in one of the arguments. Post a few lines of you code, so we can check and help more :-)

        Anselmo L. S. Melo (anselmolsm)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Seems that you do not link against QtGui lib. Did you create a .pro file with "qmake -project"?

          There are some examples in the "Getting Started Programming with Qt":http://doc.qt.nokia.com/4.7/gettingstartedqt.html guide. Translations of this guide are available in this "wiki page":http://developer.qt.nokia.com/wiki/Category:Learning::GettingStarted

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            anselmolsm
            wrote on last edited by
            #5

            [quote author="Volker" date="1291893521"]Seems that you do not link against QtGui lib. Did you create a .pro file with "qmake -project".
            [/quote]

            Good shot, Volker!
            Of course, 'undefined reference to blablalba' is a linker error. e.ustimenko, forget about what I said (but post the code, if you have other issues).

            Anselmo L. S. Melo (anselmolsm)

            1 Reply Last reply
            0
            • E Offline
              E Offline
              e.ustimenko
              wrote on last edited by
              #6

              Server.pro
              SOURCES +=
              main.cpp
              server.cpp
              thread.cpp
              dialog.cpp

              HEADERS +=
              server.h
              thread.h
              dialog.h

              install

              target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/Server/Server
              sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS Server.pro
              sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/Server/server
              INSTALLS += target sources

              symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)

              QT -= gui
              QT += network

              main.cpp
              #include <QtGui/QApplication>
              #include <QtCore>

              #include <stdlib.h>

              #include "dialog.h"

              int main(int argc, char *argv[])
              {
              QApplication app(argc, argv);
              Dialog dialog;
              dialog.show();
              qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
              return dialog.exec();
              }

              1 Reply Last reply
              0
              • A Offline
                A Offline
                anselmolsm
                wrote on last edited by
                #7

                e.ustimenko, why QT -= gui ? Doing that, you do not link against QtGui (exactly what Volker pointed out)

                Anselmo L. S. Melo (anselmolsm)

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  e.ustimenko
                  wrote on last edited by
                  #8

                  What I should write?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    Delete the line "QT -= gui" from your .pro file, run qmake again and then make.

                    Could you please put your code in @-Tags, that improves readabilitiy, because it's pretty formatted. (You can edit your post afterwards).

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      anselmolsm
                      wrote on last edited by
                      #10

                      [quote author="e.ustimenko" date="1291897495"]What I should write?[/quote]

                      As you want to use QtGui (QApplication is part of it), remove the line QT -= gui.

                      QtCore and QtGui are added by default, so this line only makes sense if you really do not want to use QtGui in you app. In this case, you should use QCoreApplication instead of QApplication.

                      Anselmo L. S. Melo (anselmolsm)

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        e.ustimenko
                        wrote on last edited by
                        #11

                        Thank you for answers.

                        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