Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt Creator - Undefined reference to...
Zikkee13 last edited by A Former User
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()'
I know it's link errors. But I don't know how to fix theses errors...
My .pro file is :
and my main.cpp is :
int main(int argc, char* argv)
QApplication app(argc, argv);
QPushButton button("Push Me");
button.show(); return app.exec();
My Qt5.0.1 folder is in /home/myusername/ .
If someone can help me... it could be great! ;D
koahnig last edited by
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.
zhxt last edited by
try to add "QT += widgets" to .pro file.
QtWidgets is seperate module in Qt5.
Zikkee13 last edited by
Thanks for your answers.
@QT += widgets@
in my .pro file it works now. Thanks Xingtao Zhang ! ;)
Mohit last edited by
an answer 4 years ago ..and now took me out of rough rush of 2 hours...Thank geeks