Qt(キュートと読むらしい)を使うことになったので、とりあえず、会社のパソコンにインストール。

トロール社のダウンロードサイトhttp://www.trolltech.com/products/qt/downloads)から、WindowsのOpenSourceEditionに行って(http://www.trolltech.com/developer/downloads/qt/windows)まずは、 http://ftp.iasi.roedu.net/mirrors/ftp.trolltech.com/qt/source/qt-win-opensource-src-4.2.3.zip を試す。

Qt用のディレクトリに展開して、

C:\home\application\Qt\4.2.3>configure.exe -platform win32-g++

This is the Qt/Windows Open Source Edition.

You are licensed to use this software under the terms of
the GNU General Public License.

Type '?' to view the GNU General Public License.
Type 'y' to accept this license offer.
Type 'n' to decline this license offer.

Do you accept the terms of the license?
y
Environment:
    INCLUDE=
      Unset
    LIB=
      Unset
    PATH=
      C:\home\application\Perl\bin\
      C:\WINDOWS\system32
      C:\WINDOWS
      C:\WINDOWS\System32\Wbem
      c:\home\application\Qt\4.2.3\bin
You are licensed to use this software under the terms of the GNU GPL.
See C:\home\application\Qt\4.2.3/LICENSE.GPL

Configuration:
    minimal-config
    small-config
    medium-config
    large-config
    full-config
    build_all
    debug
Qt Configuration:
    release
    debug
    zlib
    no-gif
    png
    accessibility
    qt3support
    opengl
    ipv6

QMAKESPEC...................win32-g++ (commandline)
Architecture................windows
Maketool....................mingw32-make
Debug symbols...............yes
Accessibility support.......yes
STL support.................yes
Exception support...........yes
RTTI support................yes
OpenGL support..............yes
Qt3 compatibility...........yes

Third Party Libraries:
    ZLIB support............qt
    GIF support.............no
    JPEG support............plugin
    PNG support.............qt
    MNG support.............plugin

Styles:
    Windows.................yes
    Windows XP..............yes
    Plastique...............yes
    Cleanlooks..............yes
    Motif...................yes
    CDE.....................yes

Sql Drivers:
    ODBC....................no
    MySQL...................no
    OCI.....................no
    PostgreSQL..............no
    TDS.....................no
    DB2.....................no
    SQLite..................plugin (qt)
    SQLite2.................no
    InterBase...............no

Sources are in..............C:\home\application\Qt\4.2.3
Build is done in............C:\home\application\Qt\4.2.3
Install prefix..............C:\home\application\Qt\4.2.3
Headers installed to........C:\home\application\Qt\4.2.3\include
Libraries installed to......C:\home\application\Qt\4.2.3\lib
Plugins installed to........C:\home\application\Qt\4.2.3\plugins
Binaries installed to.......C:\home\application\Qt\4.2.3\bin
Docs installed to...........C:\home\application\Qt\4.2.3\doc
Data installed to...........C:\home\application\Qt\4.2.3
Translations installed to...C:\home\application\Qt\4.2.3\translations
Examples installed to.......C:\home\application\Qt\4.2.3\examples
Demos installed to..........C:\home\application\Qt\4.2.3\demos


Creating qmake...
execute: File or path is not found (mingw32-make)
execute: File or path is not found (mingw32-make)
Cleaning qmake failed, return code -1


C:\home\application\Qt\4.2.3>

となって失敗。mingwってのがいるみたいなので、 http://ftp.iasi.roedu.net/mirrors/ftp.trolltech.com/qt/source/qt-win-opensource-4.2.3-mingw.exe を試す。
こいつはインストーラで、MinGWとQtを一緒に入れてくれるものだった。
が、てっきりMinGWのみと思ったので、途中で聞かれたディレクトリとかが変な感じになってしまった。

とりあえず、MinGWは、C:\MinGW に、Qtは、C:\home\appliaction\Qtmingw に。
PATHにC:\home\appliaction\Qtmingw\binとC:\MinGW\binを追加するが、Qtで使いそうなので念のためMinGWの方を先に追加した。んで、

C:\home\application\Qtmingw>configure.exe -platform win32-g++

ってやったけど、出力が長すぎて全部コピーできず。
最後は、

Qt is now configured for building. Just run mingw32-make.
To reconfigure, run mingw32-make clean and configure.


C:\home\application\Qtmingw>

となって、いけたぽ。

次に、日本でQtを取り扱っている会社(http://www.sra.co.jp/qt/)からチュートリアルの日本語版を落としてきて、早速チュートリアル1をやってみる。

Cygwin上でやったら、

hoge@hoge002 ~/qt
$ qmake -project

hoge@hoge002 ~/qt
$ ls
qt.pro  tu1.c

hoge@hoge002 ~/qt
$ qmake
Failure to read QMAKESPEC conf file /usr/lib/qt3/mkspecs/cygwin-g++\qmake.conf.
Error processing project file: C:/cygwin/home/hoge/qt/qt.pro

となってNGだった。Win上でやったらうまくいったので深く追求してない。
まずはまんま、上記のファイル(tu1.c)を持ってきたところ、

C:\home\qttest>qmake -project

C:\home\qttest>qmake

C:\home\qttest>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/home/qttest'
gcc -c -g -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_C
ORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"C:/home/application/Qtmingw/incl
ude/QtCore" -I"C:/home/application/Qtmingw/include/QtCore" -I"C:/home/applicatio
n/Qtmingw/include/QtGui" -I"C:/home/application/Qtmingw/include/QtGui" -I"C:/hom
e/application/Qtmingw/include" -I"." -I"C:/home/application/Qtmingw/include/Acti
veQt" -I"debug" -I"." -I"..\application\Qtmingw\mkspecs\default" -o debug\tu1.o
tu1.c
In file included from C:/home/application/Qtmingw/include/QtCore/qnamespace.h:1,
                 from C:/home/application/Qtmingw/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:27,
                 from C:/home/application/Qtmingw/include/QtCore/qobjectdefs.h:1,
                 from C:/home/application/Qtmingw/include/QtCore/../../src/corelib/kernel/qobject.h:29,
                 from C:/home/application/Qtmingw/include/QtCore/qobject.h:1,
                 from C:/home/application/Qtmingw/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:27,
                 from C:/home/application/Qtmingw/include/QtCore/qcoreapplication.h:1,
                 from C:/home/application/Qtmingw/include/QtGui/../../src/gui/kernel/qapplication.h:27,
                 from C:/home/application/Qtmingw/include/QtGui/qapplication.h:1,
                 from C:/home/application/Qtmingw/include/QtGui/QApplication:1,
                 from tu1.c:1:
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:31: error: syntax error before "QT_MODULE"
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:34: error: syntax error before "namespace"
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:38: error: syntax error before '{' token
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:90: warning: return type defaults to `int'
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h: In function `Q_DECLARE_FLAGS':
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:91: error: `Qt' undeclared (first use in this function)
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:91: error: (Each undeclared identifier is reported only once
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:91: error: for each function it appears in.)
C:/home/application/Qtmingw/include/QtCore/../../src/corelib/global/qnamespace.h:91: confused by earlier errors, bailing out
mingw32-make[1]: *** [debug\tu1.o] Error 1
mingw32-make[1]: Leaving directory `C:/home/qttest'
mingw32-make: *** [debug] Error 2

C:\home\qttest>

となってエラー。
たぶん、src/corelib/global/qglobal.h でC++ならむにゃむにゃしてる感じのあれが.cならそれで.cppならそれになるのだろう。深く追求しない。
ファイル名をmain.cppに変更したところ、

C:\home\qttest>qmake -project

C:\home\qttest>qmake

C:\home\qttest>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/home/qttest'
g++ -c -g -g -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL
 -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"C:/home/appl
ication/Qtmingw/include/QtCore" -I"C:/home/application/Qtmingw/include/QtCore" -
I"C:/home/application/Qtmingw/include/QtGui" -I"C:/home/application/Qtmingw/incl
ude/QtGui" -I"C:/home/application/Qtmingw/include" -I"." -I"C:/home/application/
Qtmingw/include/ActiveQt" -I"debug" -I"." -I"..\application\Qtmingw\mkspecs\defa
ult" -o debug\main.o main.cpp
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runt
ime-pseudo-reloc -Wl,-subsystem,windows -o "debug\qttest.exe" debug\main.o  -L"c
:\home\application\Qtmingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot fin
d -lqtmaind
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\qttest.exe] Error 1
mingw32-make[1]: Leaving directory `C:/home/qttest'
mingw32-make: *** [debug] Error 2

C:\home\qttest>

となり、main.oはコンパイルできたが、リンクできない様子。qtmaindでぐぐったら、2chに情報あり。
どうも、デバッグライブラリってのが必要で、WinのOpen Source版をインストールしただけだとリリース版のライブラリしかできないようだ。
スタート→Qt by Trolltech v4.2.3 (OpenSource)→Qt 4.2.3 (Build Debug Libraries)
で、ライブラリを作って再度トライ。

C:\home\qttest>make
qmake -win32 -o Makefile qttest.pro
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/home/qttest'
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runt
ime-pseudo-reloc -Wl,-subsystem,windows -o "debug\qttest.exe" debug\main.o  -L"c
:\home\application\Qtmingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/home/qttest'

C:\home\qttest>

debugディレクトリにqttest.exeができていて無事動いた。
その後の実験の結果、ファイル名は任意のようだが、拡張子は.cだとNGで、
.cppだといけるようだ。

昨日はそんな感じだった。
今日は、本番環境でFedora上で動かすので、Fedoraのインストールからしてま。