I am writing this simple Qt application, but it is showing the following errors.
Can anyone explain me why I am getting these errors? Below is the code snippet:
#include <QTextStream>
int main()
{
QTextStream out(stdout);
out << "console application\n";
}
Steps followed to compile:
qmake -project
qmake .pro file
make
After following the above mentioned steps, below is the output that I’m getting:
g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o text.o text.cpp
text.cpp:1:23: error: QTextStream: No such file or directory
text.cpp: In function ‘int main()’:
text.cpp:5: error: ‘QTextStream’ was not declared in this scope
text.cpp:5: error: expected ‘;’ before ‘out’
text.cpp:6: error: ‘out’ was not declared in this scope
make: *** [text.o] Error 1
Platform: Linux
Use
qmakeandmakeinstead of manually invoking the compiler.and make sure the
qmakeversion you’re invoking is the Qt4 version, not the Qt3. You seem to have both versions installed, and you’re probably invoking the Qt3 one.Try this:
The output should be something like this
To be sure you’re invoking the right
qmake(Qt4), usually you can replaceqmakecommands withqmake-qtX, whereXis the Qt version.