Since I wanted to port some Qt4 applications (I always developed under Linux) in Windows, I downloaded from the trolltech site the Qt libraries for Windows (already compiled) which come with a minimal MinGW compiler to build windows applications. This was the first time I was using mingw, since I've always used cygwin instead.
The Qt installation comes with a start menu item called Qt Command Prompt, which sets all the environment variables for you in order to start building Qt applications.
I tried to build a Qt tutorial example with qmake in msys, and here comes the bad surprise: the Makefiles generated by qmake contains windows paths (e.g., for calling the moc compiler), which the Unix shell does not understand. Here's a screenshot with the error:
C:\Qt\4.4.3\bin/moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/Qt/4.4.3/include/QtCore' -I'c:/Qt/4.4.3/include/QtCore' -I'c:/Qt/4.4.3/include/QtGui' -I'c:/Qt/4.4.3/include/QtGui' -I'c:/Qt/4.4.3/include' -I'c:/Qt/4.4.3/include/ActiveQt' -I'debug' -I'.' -I'c:/Qt/4.4.3/mkspecs/default' -D__GNUC__ -DWIN32 cannonfield.h -o debug/moc_cannonfield.cppI then asked on the nice qtcentre forum, and they pointed me to this blog post where they says it's a well known problem, and that recently Qt can be used also from msys (since qmake will generate Unix shell paths). What wasn't clear to me was that you must recompile Qt libraries yourself to make it work also from msys.
make: C:Qt4.4.3bin/moc.exe: Command not found
make: *** [debug/moc_cannonfield.cpp] Error 127
That's what I've done, downloading the sources of Qt and compiling the libraries from msys.
IMPORTANT: I wasn't able to compile the Qt libraries with the standard MinGW distribution; I had to use the MinGW that comes with Qt installation (i.e., the file qt-win-opensource-4.4.3-mingw.exe).
I did this procedure:
- Set some environment variables (assuming that you unzip the sources in C:\qt-win-opensource-src-4.4.3:
- then you can run configure.exe (this will create the qmake binary and all the Makefiles)
- now run make and wait for about 3 hours!
Couldn't reserve space for cygwin's heap...
Now, if no other errors take place, you'll have your compiled Qt libraries, and binaries, that generate the right Makefiles.
By removing the previous Makefiles, running qmake again (this time it will generate Unix paths to executables), and then make, everything works fine, and you can build qt applications from the comfortable Unix shell: indeed, now, the moc invocation command line is:
C:/qt-win-opensource-src-4.4.3/bin/moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/qt-win-opensource-src-4.4.3/include/QtCore' -I'c:/qt-win-opensource-src-4.4.3/include/QtCore' -I'c:/qt-win-opensource-src-4.4.3/include/QtGui' -I'c:/qt-win-opensource-src-4.4.3/include/QtGui' -I'c:/qt-win-opensource-src-4.4.3/include' -I'c:/qt-win-opensource-src-4.4.3/include/ActiveQt' -I'debug' -I'.' -I'c:/qt-win-opensource-src-4.4.3/mkspecs/win32-g++' -D__GNUC__ -DWIN32 lcdrange.h -o debug/moc_lcdrange.cpp