Qt Application is copiling from IDE but giving error while building from teminal?
Hi,
I am new to Qt.
I have installed Qt_SDK_Lin32_offline_v1_1_2_en.run. It has installed successfuly.
When i have created Qt application from Qt IDE, it is building and running but same application is giving error when i try to compile it from terminal.
My code is
.pro file:
Code:
SOURCES = main.cpp
# install
sources.files = $$SOURCES *.pro
INSTALLS += target sources
DESTDIR = release
TARGET = Demo
main.cpp
Code:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
label
->setPixmap
(QPixmap(200,
50));
label->show();
return app.exec();
}
but when i try to compile same project from command line using qmake and make command then it is giving following error.
Code:
$qmake
WARNING: target.path is not defined: install target not created
WARNING: sources.path is not defined: install target not created
$make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -o main.o main.cpp
main.
cpp:1:24: fatal error
: QApplication: No such
file or directory
compilation terminated.
make: *** [main.o] Error 1
I have compiled another project which is working fine in command line on another system with qmake and make. It is not giving any warning while qmake but giving same error while make.
.pro file for another project is
Code:
SOURCES = main.cpp
# install
target.path = Demo
sources.files = $$SOURCES *.pro
sources.path = .
INSTALLS += target sources
main.cpp is same for both.
Please help me to solve this.
Thanks
Re: Qt Application is copiling from IDE but giving error while building from teminal?
What's the purpose of wanting to copy all the sources and project file into current directory? What's the purpose of trying to copy the target executable to a "Demo" directory? What does /usr/include/qt4/QtGui contain? What does qmake -v return?
Re: Qt Application is copiling from IDE but giving error while building from teminal?
Thanks Wysota for your response.
Quote:
What's the purpose of wanting to copy all the sources and project file into current directory? What's the purpose of trying to copy the target executable to a "Demo" directory?
I am doing same on another system. previously i was unaware about Qt creator and designed forms in Qt Designer, write .cpp and .h files for forms and used qmake and make commands to compile and link the application.
Now i am using Qt creator and want to load and compile the old projects with Qt creator which are on another system (old means 7 days old, i have started Qt 7 days ago).
Quote:
What does /usr/include/qt4/QtGui contain?
/usr/include not contains any folder named Qt4 ot Qt. /usr/lib contains a folder named Qt4.
Quote:
What does qmake -v return?
it is returning
QMake version 2.01a
Using Qt version 4.7.4 in /usr/lib/i386-linux-gnu
Thanks.
Re: Qt Application is copiling from IDE but giving error while building from teminal?
Quote:
Originally Posted by
gurmeetsingh
I am doing same on another system. previously i was unaware about Qt creator and designed forms in Qt Designer, write .cpp and .h files for forms and used qmake and make commands to compile and link the application.
This does not explain why you would want to copy the source code to the current dirrectory while installing the application.
Quote:
/usr/include not contains any folder named Qt4 ot Qt. /usr/lib contains a folder named Qt4.
So you don't have development headers for Qt installed in the location qmake is looking for them.
Quote:
it is returning
QMake version 2.01a
Using Qt version 4.7.4 in /usr/lib/i386-linux-gnu
I would assume your QtCreator build uses a different Qt installation (bundled with QtSDK).
You either need to install appropriate packages for your system (like qt4-devel, libqt4-devel, qt4-dev, libqt4-dev or similar) or use qmake from the installation bundled with QtSDK.
Re: Qt Application is copiling from IDE but giving error while building from teminal?
Thanks Wysota for your reply.
Quote:
You either need to install appropriate packages for your system (like qt4-devel, libqt4-devel, qt4-dev, libqt4-dev or similar) or use qmake from the installation bundled with QtSDK.
I have installed libqt4-dev using command apt-get install libqt4-dev. Now it is working fine.
Thanks.