Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Undefined reference to `QApplication::QApplication(int&, char**, int)
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
maciej last edited by
Could you post code which is causing problems?
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 :-)
goetz last edited by
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
[quote author="Volker" date="1291893521"]Seems that you do not link against QtGui lib. Did you create a .pro file with "qmake -project".
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).
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
QT -= gui
QT += network
int main(int argc, char *argv)
QApplication app(argc, argv);
e.ustimenko, why QT -= gui ? Doing that, you do not link against QtGui (exactly what Volker pointed out)
What I should write?
goetz last edited by
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).
[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.
Thank you for answers.