Qt World Summit: Submit your Presentation

Qt Creator - Undefined reference to...

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

    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");

    return  app.exec(&#41;;


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

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


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

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

    QtWidgets is seperate module in Qt5.

  • Thanks for your answers.


    @QT += widgets@

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

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

Log in to reply