Qmake -project, qmake Work But make doesn't work
-
I am new to Qt and linux.I have installed Qt(Everywhere- ver -4.6.3) Ubuntu 10 in to the default folder /usr/local/Trolltech.
i have written following Hello World program.@
#include<qapplication.h>
#include<qpushbutton.h>int main(int argc, char **argv)
{
QApplication a(argc,argv);
QPushButton hello("Hello world!",0);hello.resize(100,30);
hello.show();
return a.exec();
}*
@
i entered following commands
@
qmake -project ( .pro file created using directory name)
qmake ( Makefile created)
@
Then enter makefollowing message appeared i could imagine the cause for that My file name is *HelloQt*
@
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.6.3/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.6.3/include/QtCore -I/usr/local/Trolltech/Qt-4.6.3/include/QtGui -I/usr/local/Trolltech/Qt-4.6.3/include -I. -I. -o HelloQt.o HelloQt.cpp
g++ -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.6.3/lib -o exampleQt HelloQt.o -L/usr/local/Trolltech/Qt-4.6.3/lib -lQtGui -L/usr/local/Trolltech/Qt-4.6.3/lib -L/usr/X11R6/lib -lQtCore -lpthread
@g++ is installed. Please can anyone help me in this trivial question.?
[Edit: please use @-formatting for code, peppe]
-
Welcome to forum.
your code @#include<qapplication.h>
#include <qpushbutton.h>int main(int argc, char **argv)
{
QApplication a(argc,argv);
QPushButton hello("Hello world!",0);
hello.resize(100,30);
hello.show();
return a.exec();
}@works fine for me. Except that, i changed the @“@ to @"@
-
You do not have any error at all (at least you did not paste them), the output are the usual compile steps (compiling main.cpp and linking).
Your executable is named exampleQt. The default for qmake is to name the project file (.pro) and the executable the same as the directory "qmake -project" is run in.
-
Thanks for reply. You can see when enter make it tries to implement the Makefile but it is not finding paths to the includes/ libraries. Is this problem of g++ command? or installation?
I tried to do it in command line like this,
g++ HelloQt.cpp -o HelloQt -I/usr/local/Trolltech/Qt-4.6.3/include -lQtGui -lQtCore
Then following error appeared
HelloQt.cpp:1:25: error: qapplication.h: No such file or directory
HelloQt.cpp:2:24: error: qpushbutton.h: No such file or directory
HelloQt.cpp: In function ‘int main(int, char**)’:
HelloQt.cpp:6: error: ‘QApplication’ was not declared in this scope
HelloQt.cpp:6: error: expected ‘;’ before ‘a’
HelloQt.cpp:7: error: ‘QPushButton’ was not declared in this scope
HelloQt.cpp:7: error: expected ‘;’ before ‘hello’
HelloQt.cpp:9: error: ‘hello’ was not declared in this scope
HelloQt.cpp:12: error: ‘a’ was not declared in this scopeDo you have any idea for this error?
[quote author="Volker" date="1326664992"]You do not have any error at all (at least you did not paste them), the output are the usual compile steps (compiling main.cpp and linking).
Your executable is named exampleQt. The default for qmake is to name the project file (.pro) and the executable the same as the directory "qmake -project" is run in.[/quote]
-
your g++ command line differs significantly from that of your first post, so why should that work?
I don't get your problem at all. Your stanza of
@
qmake -project
qmake
make
@worked as expected and without any error.
Your executable is in the file exampleQt, just start it and you're done.