PDA

View Full Version : Qt Application is copiling from IDE but giving error while building from teminal?



gurmeetsingh
26th January 2012, 14:08
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:


SOURCES = main.cpp
# install
sources.files = $$SOURCES *.pro
INSTALLS += target sources
DESTDIR = release
TARGET = Demo

main.cpp


#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
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.

$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


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

wysota
26th January 2012, 14:31
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?

gurmeetsingh
27th January 2012, 07:32
Thanks Wysota for your response.



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).


What does /usr/include/qt4/QtGui contain?

/usr/include not contains any folder named Qt4 ot Qt. /usr/lib contains a folder named Qt4.


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.

wysota
27th January 2012, 09:36
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.


/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.


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.

gurmeetsingh
31st January 2012, 08:59
Thanks Wysota for your reply.


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.