Undefined reference to `QApplication::QApplication(int&, char**, int)
-
wrote on 9 Dec 2010, 11:06 last edited by
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 -
wrote on 9 Dec 2010, 11:14 last edited by
Hi Evgeny,
Could you post code which is causing problems?
-
wrote on 9 Dec 2010, 11:17 last edited by
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 :-)
-
wrote on 9 Dec 2010, 11:18 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
-
wrote on 9 Dec 2010, 11:22 last edited by
[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). -
wrote on 9 Dec 2010, 12:19 last edited by
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();
} -
wrote on 9 Dec 2010, 12:21 last edited by
e.ustimenko, why QT -= gui ? Doing that, you do not link against QtGui (exactly what Volker pointed out)
-
wrote on 9 Dec 2010, 12:24 last edited by
What I should write?
-
wrote on 9 Dec 2010, 12:29 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).
-
wrote on 9 Dec 2010, 12:29 last edited by
[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.
-
wrote on 9 Dec 2010, 13:42 last edited by
Thank you for answers.
1/11