You are not logged in.

#1 2014-01-03 01:50:53

publicus
Member
Registered: 2014-01-01
Posts: 129

[SOLVED] Unable to compile QT4 application

This is the code that I have:

#include <QApplication>
#include <QWidget>

int main(int argc, char * argv[])
{
  QApplication app(argc, argv);

  QWidget window;

  window.resize(250, 150);
  window.setWindowTitle("Simple example");
  window.show();

  return app.exec();
}

This is the error that I get:

g++ -c -pipe -march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I. -I. -I/usr/include/qt -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -o hello_world.o hello_world.cpp
hello_world.cpp:3:24: fatal error: QApplication: No such file or directory
 #include <QApplication>
                        ^
compilation terminated.
Makefile:298: recipe for target 'hello_world.o' failed
make: *** [hello_world.o] Error 1

These are the other threads that I researched.
https://bbs.archlinux.org/viewtopic.php?id=66927
https://bbs.archlinux.org/viewtopic.php?id=37815

When I did a search for "qt4" in "/", this is what I got:

./usr/include/qt4
./usr/share/qt4
./usr/share/licenses/qt4
./usr/lib/qt4

Now, why are these headers not detected?

Last edited by publicus (2014-01-03 18:21:27)

Offline

#2 2014-01-03 07:42:17

teekay
Member
Registered: 2011-10-26
Posts: 270

Re: [SOLVED] Unable to compile QT4 application

Your g++ -I include paths point to Qt5.

Offline

#3 2014-01-03 12:32:32

publicus
Member
Registered: 2014-01-01
Posts: 129

Re: [SOLVED] Unable to compile QT4 application

teekay wrote:

Your g++ -I include paths point to Qt5.

How do I set it to Qt4?

Offline

#4 2014-01-03 18:20:12

publicus
Member
Registered: 2014-01-01
Posts: 129

Re: [SOLVED] Unable to compile QT4 application

I got it!  I used the tool qtchooser to run qmake so that when the Makefile is generated, it's generated with Qt4 in mind.  The process was something like this:

qmake -project && qtchooser -run-tool=qmake -qt=4 && make

Offline

#5 2014-01-03 18:21:34

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,126

Re: [SOLVED] Unable to compile QT4 application

There is also qmake-qt4

Offline

#6 2014-01-03 18:24:00

publicus
Member
Registered: 2014-01-01
Posts: 129

Re: [SOLVED] Unable to compile QT4 application

Scimmia wrote:

There is also qmake-qt4

And I learned something new cool .

Offline

Board footer

Powered by FluxBB