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. Qt Creator - Undefined reference to...
Forum Updated to NodeBB v4.3 + New Features

Qt Creator - Undefined reference to...

Scheduled Pinned Locked Moved Solved Installation and Deployment
5 Posts 4 Posters 37.7k Views 1 Watching
  • 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.
  • Z Offline
    Z Offline
    Zikkee13
    wrote on last edited by A Former User
    #1

    Hello everybody,

    I just intalled Qt Creator on my Ubuntu 12.10 (Qt 5.0 : library+Qt Creator on this webpage : http://qt-project.org/downloads).
    But I have buikd errors :

    • /home/myusername/Documents/Cpp/Qt/testQt-build-Desktop_Qt_5_0_1_GCC_32bit-Debug/../testQt/main.cpp:7: undefined reference to `QApplication::QApplication(int&, char**, int)'
    • /home/myusername/Documents/Cpp/Qt/testQt-build-Desktop_Qt_5_0_1_GCC_32bit-Debug/../testQt/main.cpp:8: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
    • /home/myusername/Documents/Cpp/Qt/testQt-build-Desktop_Qt_5_0_1_GCC_32bit-Debug/../testQt/main.cpp:10: undefined reference to `QWidget::show()'
    • Etc.

    I know it's link errors. But I don't know how to fix theses errors...
    My .pro file is :

    @SOURCES +=
    main.cpp@

    and my main.cpp is :

    @#include <iostream>
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QPushButton>

    int main(int argc, char* argv[])
    {
    QApplication app(argc, argv);
    QPushButton button("Push Me");

    button.show();
    
    return  app.exec(&#41;;
    

    }@

    My Qt5.0.1 folder is in /home/myusername/ .

    If someone can help me... it could be great! ;D

    Thanks!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to devnet

      It looks a bit as you are using qt creator only as editor. The pro-file should have some more statements.

      Start out in qt creator with a fresh new project based on template "Qt GUI application". I would assume that this would help, if the overall setup is correct.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zhxt
        wrote on last edited by
        #3

        try to add "QT += widgets" to .pro file.

        QtWidgets is seperate module in Qt5.
        http://doc-snapshot.qt-project.org/5.0/qtwidgets/qtwidgets-index.html

        Qt Developer

        1 Reply Last reply
        1
        • Z Offline
          Z Offline
          Zikkee13
          wrote on last edited by
          #4

          Thanks for your answers.

          With

          @QT += widgets@

          in my .pro file it works now. Thanks Xingtao Zhang ! ;)

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mohit
            wrote on last edited by
            #5

            an answer 4 years ago ..and now took me out of rough rush of 2 hours...Thank geeks

            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