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
QT-version: 4.7.1 -
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 :-)
-
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".
[/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). -
Server.pro
SOURCES +=
main.cpp
server.cpp
thread.cpp
dialog.cppHEADERS +=
server.h
thread.h
dialog.hinstall
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 sourcessymbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
QT -= gui
QT += networkmain.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();
} -
e.ustimenko, why QT -= gui ? Doing that, you do not link against QtGui (exactly what Volker pointed out)
-
What I should write?
-
[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.