0

I wrote a text editor application which I want to compile statically. I followed the instructions outlined on this page.

I went to the directory where all the source files were. Ran:

1. mingw32-make clean //no problems
2. qmake -config release //no problems
and finally
3. mingw32-make

, and that's where I got a list of errors all caused by the #include statements in my code. Like, if I wrote #include <QMainWindow>, i'd get an error

QMainWindow: no such file or directory.

What am I doing wrong?

W.K.S
  • 9,787
  • 15
  • 75
  • 122
  • you mean, did I write #include ? Nope. I tried to see if it worked that way but no luck. – W.K.S Dec 05 '11 at 20:24
  • What's probably happening is that `qmake` reference the directory where the Qt headers reside, whereas with `mingw32-make` you would have to specify them explicitly – Ken Wayne VanderLinde Dec 05 '11 at 20:28
  • I believe you need to run `qmake` as the MOC is needed for classes containing the `Q_OBJECT` macro such as `QMainWindow` will have. Two phase compilation is one of the few downsides of Qt. – AJG85 Dec 05 '11 at 20:37
  • Wait, do you mean run qmake in step 2? I did that - sorry I made a mistake when I typed my steps. I've edited it now. – W.K.S Dec 05 '11 at 20:50
  • In that case it probably is failing to find your Qt directory. Are your environment variables set correctly? – AJG85 Dec 05 '11 at 21:02
  • I'm not sure. Is there a way I could check whether they're correct or not? – W.K.S Dec 06 '11 at 19:25

2 Answers2

1

In MSVC2010 using qmake nmake I resolved this by replacing instances of

#include <QMainWindow>

with

#include <QtWidgets/QMainWindow>
Guy Cook
  • 552
  • 4
  • 17
0

In your .pro try this line: "QT += gui"

Rodrigo
  • 135
  • 4
  • 45
  • 107