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
SOURCES = main.cpp
# install
sources.files = $$SOURCES *.pro
INSTALLS += target sources
DESTDIR = release
TARGET = Demo
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
label
->setPixmap
(QPixmap(200,
50));
label->show();
return app.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
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
$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
To copy to clipboard, switch view to plain text mode
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
SOURCES = main.cpp
# install
target.path = Demo
sources.files = $$SOURCES *.pro
sources.path = .
INSTALLS += target sources
To copy to clipboard, switch view to plain text mode
main.cpp is same for both.
Please help me to solve this.
Thanks
Bookmarks