MinGWコンパイルQt
参考:
http://wiki.batcom-it.net/index.php?title=Building_Qt_うむWindowsu%28 MinGW%29
http://harmattan-dev.nokia.com/docs/library/html/qt4/install-win.html
テストマシン:windows 7 x 64、mingw 32、qt-4.8.5
1)qtのソースコードをダウンロードする
http://download.qt-project.org/official_releases/qt/4.8/4.8/qt-everywhere-opensource-src-4.85.tar.gz
2)mingw 32ツールチェーンをダウンロードする
git clone git://code.csdn.net/wuzh1230/bitcoin.git
3)ストレス解消と配置
できれば綺麗なコードの上でgitのバックアップをしたほうがいいです。でないと、qtが大きすぎて、これらのファイルの修正に気づきにくいです。
git init.&git add.&git comit-m「add clean sources」
設定:
windowsのconfigure.exeを使って配置命令を実行します。そうでないとqmakeはMakefile.unixを使って構築し、さらに失敗します。
chlpでqt configure optionsのあれらの事を見てみます。
(d/cifs/labのようなcygwin経路をd:/cifs/labのようなwindowsパスに切り替える必要があるかもしれません)
どうやってコンパイルを加速しますか?
-nomake demos、-nomake examples、-nomake tools
膨大なexamplesは多くのコンパイル時間とディスク空間を消費します。
これらのFeatureが含まれているコンポーネントを確認してください。
長い間待っています。
mingw 32-make
朝来てみたら、\src\plugins\bearrativewifi\main.cppは失敗しました。原因は間接的に<wctypes.h>を引用しましたが、windowsプラットフォームの先頭ファイルを引用していません。前に、plotformdefs.hを修正しました。
はコンパイルを続けましょう。。。。。
約1時間が過ぎました。完成しました。
そして設置場所はどこですか?
現在の経路がd:\abc\qt-sourceであれば、d:\dest\abc\qt-source\にインストールされます。why?
6)Qtライブラリでプログラムを構築する
三つのステップ
6.1)qmakeのパスをpathに設定する、つまり上の図のインストール後のディレクトリのbinディレクトリです。
$export PATH=$PATH:/d/cifs/lab/csdn/bitcoin/3 rd/qt-4.8.5-mingw 32-4.8.1/bin
6.2)exampleディレクトリの下でsampleを探して、qmakeを実行してMakefileを生成します。
コピーに依存するdllを実行可能な例のプログラムディレクトリに記憶してください。
実行:
問題の追跡:
(1)confgure.exeとconfigureスクリプトの違い
sh configure-plotform win 32-g+-opensource-confirm-licenseを実行すると構成スクリプトがqmake/Makefile.unixファイルを引用することになります。なぜですか?ユニコムのマクロが定義されていないため、Qmake/project.cppがコンパイルできなくなりました。
期待されるのは、win 32ウィンドウシステム上で実行されるqtをコンパイルすることです。x 11サポートのqtではなく、linux上ではconfigurシナリオしか実行できません。このスクリプトはデフォルトではlinuxのx 11のために作成されています。
方案一(未テスト):configure.exe構成を使用して、CROSS_COMPILE=i 686-w 64-mingw 32-gmakeをコンパイルします。
方案二(未テスト):
(3)msvc 2008の設定スクリプトを添付します。
http://wiki.batcom-it.net/index.php?title=Building_Qt_うむWindowsu%28 MinGW%29
http://harmattan-dev.nokia.com/docs/library/html/qt4/install-win.html
テストマシン:windows 7 x 64、mingw 32、qt-4.8.5
1)qtのソースコードをダウンロードする
http://download.qt-project.org/official_releases/qt/4.8/4.8/qt-everywhere-opensource-src-4.85.tar.gz
2)mingw 32ツールチェーンをダウンロードする
git clone git://code.csdn.net/wuzh1230/bitcoin.git
3)ストレス解消と配置
できれば綺麗なコードの上でgitのバックアップをしたほうがいいです。でないと、qtが大きすぎて、これらのファイルの修正に気づきにくいです。
git init.&git add.&git comit-m「add clean sources」
設定:
windowsのconfigure.exeを使って配置命令を実行します。そうでないとqmakeはMakefile.unixを使って構築し、さらに失敗します。
chlpでqt configure optionsのあれらの事を見てみます。
Usage: configure [-buildkey <key>]
[-release] [-debug] [-debug-and-release] [-shared] [-static]
[-no-fast] [-fast] [-no-exceptions] [-exceptions]
[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]
[-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]
[-plugin-sql-<driver>] [-system-sqlite] [-arch <arch>]
[-D <define>] [-I <includepath>] [-L <librarypath>]
[-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]
[-no-qmake] [-qmake] [-dont-process] [-process]
[-no-style-<style>] [-qt-style-<style>] [-redo]
[-saveconfig <config>] [-loadconfig <config>]
[-qt-zlib] [-system-zlib] [-no-gif] [-no-libpng]
[-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]
[-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]
[-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]
[-no-mmx] [-3dnow] [-no-3dnow] [-sse] [-no-sse] [-sse2] [-no-sse2]
[-no-iwmmxt] [-iwmmxt] [-openssl] [-openssl-linked]
[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]
[-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]
[-phonon] [-no-phonon-backend] [-phonon-backend]
[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]
[-no-script] [-script] [-no-scripttools] [-scripttools]
[-no-webkit] [-webkit] [-webkit-debug]
[-graphicssystem raster|opengl|openvg]
[-no-directwrite] [-directwrite] [-no-nis] [-nis] [-qpa]
[-no-cups] [-cups] [-no-iconv] [-iconv] [-sun-iconv] [-gnu-iconv]
[-neon] [-no-neon] [-largefile] [-little-endian] [-big-endian]
[-font-config] [-no-fontconfig] [-posix-ipc]
qmakeを設定して生成します。configure.exe -platform win32-g++ -opensource -confirm-license -release -shared -nis -no-s60
opensslサポートが必要なら、opensslを構築してください。またはビルのgitにプリコンパイルのoensslをダウンロードしてください。その後、mingwコマンドラインで以下のスクリプト構成Qtを使用します。(d/cifs/labのようなcygwin経路をd:/cifs/labのようなwindowsパスに切り替える必要があるかもしれません)
configure.exe \
-I /d/cifs/lab/csdn/bitcoin/3rd/openssl-1.0.1c-mgw/include \
-L /d/cifs/lab/csdn/bitcoin/3rd/openssl-1.0.1c-mgw/lib \
-l ssl \
-l crypto \
-platform win32-g++ \
-opensource -confirm-license \
-release -shared -openssl -nis -no-s60
configure.exe \
-I "D:\workspace\MinGW64\msys\1.0\local\ssl\include" \
-L "D:\workspace\MinGW64\msys\1.0\local\ssl\lib" \
-l ssl \
-l crypto \
-platform win32-g++ \
-opensource \
-confirm-license \
-release \
-static \
-openssl \
-nis \
-no-s60
windows 7の究極のシナリオconfigure.exe \
-I "/usr/local/ssl/include" \
-L "/usr/local/ssl/lib" \
-l ssl \
-l crypto \
-release \
-opensource \
-confirm-license \
-static \
-no-ltcg \
-no-fast \
-exceptions \
-accessibility \
-stl \
-no-sql-sqlite \
-no-qt3support \
-no-opengl \
-no-openvg \
-platform win32-g++ \
-no-system-proxies \
-qt-zlib \
-no-gif \
-qt-libpng \
-no-libmng \
-no-libtiff \
-qt-libjpeg \
-no-dsp \
-no-vcproj \
-no-incredibuild-xge \
-plugin-manifests \
-qmake \
-process -nomake demos -nomake examples -nomake tools \
-no-rtti \
-no-mmx \
-no-3dnow \
-no-sse \
-no-sse2 \
-openssl \
-no-dbus \
-no-phonon -no-phonon-backend \
-no-multimedia -no-audio-backend \
-no-webkit \
-no-script -no-scripttools -no-declarative \
-arch windows \
-no-style-plastique \
-no-style-windowsxp -no-style-windowsvista \
-no-style-cleanlooks -no-style-cde \
-no-style-motif \
-no-native-gestures \
-saveconfig csdnbuild
削除しました -no-accessibility \
はcodecsのためにaccessibilityサポートが必要です。どうやってコンパイルを加速しますか?
-nomake demos、-nomake examples、-nomake tools
膨大なexamplesは多くのコンパイル時間とディスク空間を消費します。
これらのFeatureが含まれているコンポーネントを確認してください。
長い間待っています。
Qt is now configured for building. Just run mingw32-make.
To reconfigure, run mingw32-make confclean and configure.
4)Qtライブラリを生成するmingw 32-make
朝来てみたら、\src\plugins\bearrativewifi\main.cppは失敗しました。原因は間接的に<wctypes.h>を引用しましたが、windowsプラットフォームの先頭ファイルを引用していません。前に、plotformdefs.hを修正しました。
index 4e0f6d5..7f8abf2 100644
--- a/src/plugins/bearer/nativewifi/platformdefs.h
+++ b/src/plugins/bearer/nativewifi/platformdefs.h
@@ -42,7 +42,10 @@
#ifndef PLATFORMDEFS_H
#define PLATFORMDEFS_H
-#include <wtypes.h>
+#ifdef Q_OS_WIN
+#include "../platformdefs_win.h"
+#endif
+
#undef interface
//proper header is wlanapi.h, but that is not included in windows XP
mingwのヘッダファイルを修正するか、〹2047はコンパイルを続けましょう。。。。。
約1時間が過ぎました。完成しました。
g++ -c -pipe -O2 -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DLOG_SPECTRUMANALYSER -DLOG_ENGINE -DSUPERIMPOSE
_PROGRESS_ON_WAVEFORM -DSPECTRUM_ANALYSER_SEPARATE_THREAD -D_CRT_SECURE_NO_WARNINGS -DQT_DLL -DQT_NO_DEBUG -DQT_MULTIMED
IA_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREA
D_SUPPORT -DQT_NEEDS_QMAIN -I'../../../include/QtCore' -I'../../../include/QtGui' -I'../../../include/QtMultimedia' -I'.
./../../include' -I'../3rdparty/fftreal' -I'../../../include/ActiveQt' -I'tmp/moc/release_shared' -I'../../../mkspecs/wi
n32-g++' -o tmp/obj/release_shared/qrc_spectrum.o tmp/rcc/release_shared/qrc_spectrum.cpp
g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o ../release/spectrum.exe object_script.spectrum.Release -L'd:/cifs/lab/te
mp/buildqt/qt-everywhere-opensource-src-4.8.5/lib' -L'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/lib' -
lmingw32 -lqtmain -L../release -lfftreal -lQtMultimedia4 -lQtGui4 -lQtCore4
mingw32-make[4]: Leaving directory 'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/demos/spectrum/app'
mingw32-make[3]: Leaving directory 'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/demos/spectrum/app'
mingw32-make[2]: Leaving directory 'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/demos/spectrum'
mingw32-make[1]: Leaving directory 'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/demos'
5)取り付けmingw32-make install INSTALL_ROOT=dest
も長くかかります。。。。そして設置場所はどこですか?
現在の経路がd:\abc\qt-sourceであれば、d:\dest\abc\qt-source\にインストールされます。why?
6)Qtライブラリでプログラムを構築する
三つのステップ
6.1)qmakeのパスをpathに設定する、つまり上の図のインストール後のディレクトリのbinディレクトリです。
$export PATH=$PATH:/d/cifs/lab/csdn/bitcoin/3 rd/qt-4.8.5-mingw 32-4.8.1/bin
6.2)exampleディレクトリの下でsampleを探して、qmakeを実行してMakefileを生成します。
Administrator@harrywu-PC /d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs
$ cd findfiles/
Administrator@harrywu-PC /d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs/findfiles
$ ls
findfiles.exe findfiles.pro main.cpp window.cpp window.h
Administrator@harrywu-PC /d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs/findfiles
$ qmake
Administrator@harrywu-PC /d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs/findfiles
$ ls
Makefile Makefile.Release findfiles.exe main.cpp window.cpp
Makefile.Debug debug findfiles.pro release window.h
6.3)make relase生成試験を実行する例Administrator@harrywu-PC /d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs/findfiles
$ make release
make -f Makefile.Release
make[1]: Entering directory `/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs/findfiles'
g++ -c -pipe -O2 -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
-DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'd:/
cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include/QtCore' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opens
ource-src-4.8.5/include/QtGui' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include' -I'd:/cifs/lab/te
mp/buildqt/qt-everywhere-opensource-src-4.8.5/include/ActiveQt' -I'release' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-op
ensource-src-4.8.5/mkspecs/default' -o release/main.o main.cpp
g++ -c -pipe -O2 -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
-DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'd:/
cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include/QtCore' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opens
ource-src-4.8.5/include/QtGui' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include' -I'd:/cifs/lab/te
mp/buildqt/qt-everywhere-opensource-src-4.8.5/include/ActiveQt' -I'release' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-op
ensource-src-4.8.5/mkspecs/default' -o release/window.o window.cpp
D:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/bin/moc.exe -DUNICODE -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -D
QT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_Q
MAIN -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include/QtCore' -I'd:/cifs/lab/temp/buildqt/qt-every
where-opensource-src-4.8.5/include/QtGui' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include' -I'd:/
cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include/ActiveQt' -I'release' -I'd:/cifs/lab/temp/buildqt/qt-ev
erywhere-opensource-src-4.8.5/mkspecs/default' -D__GNUC__ -DWIN32 window.h -o release/moc_window.cpp
g++ -c -pipe -O2 -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
-DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'd:/
cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include/QtCore' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opens
ource-src-4.8.5/include/QtGui' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/include' -I'd:/cifs/lab/te
mp/buildqt/qt-everywhere-opensource-src-4.8.5/include/ActiveQt' -I'release' -I'd:/cifs/lab/temp/buildqt/qt-everywhere-op
ensource-src-4.8.5/mkspecs/default' -o release/moc_window.o release/moc_window.cpp
g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o release/findfiles.exe release/main.o release/window.o release/moc_window.
o -L'd:/cifs/lab/temp/buildqt/qt-everywhere-opensource-src-4.8.5/lib' -lmingw32 -lqtmain -lQtGui4 -lQtCore4
make[1]: Leaving directory `/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/examples/dialogs/findfiles'
7)試験例プログラムコピーに依存するdllを実行可能な例のプログラムディレクトリに記憶してください。
実行:
問題の追跡:
(1)confgure.exeとconfigureスクリプトの違い
sh configure-plotform win 32-g+-opensource-confirm-licenseを実行すると構成スクリプトがqmake/Makefile.unixファイルを引用することになります。なぜですか?ユニコムのマクロが定義されていないため、Qmake/project.cppがコンパイルできなくなりました。
#mkspecs/default is used as a (gasp!) default mkspec so QMAKESPEC needn't be set once configured
rm -rf mkspecs/default
ln -s `echo $XQMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` mkspecs/default
# fix makefiles
for mkfile in GNUmakefile Makefile; do
EXTRA_LFLAGS=
EXTRA_CFLAGS=
in_mkfile="${mkfile}.in"
if [ "$mkfile" = "Makefile" ]; then
# if which qmake >/dev/null 2>&1 && [ -f qmake/qmake.pro ]; then
# (cd qmake && qmake) >/dev/null 2>&1 && continue
# fi
in_mkfile="${mkfile}.unix"
(2)もしlinuxでmingw 32でクロスコンパイルするならqt期待されるのは、win 32ウィンドウシステム上で実行されるqtをコンパイルすることです。x 11サポートのqtではなく、linux上ではconfigurシナリオしか実行できません。このスクリプトはデフォルトではlinuxのx 11のために作成されています。
方案一(未テスト):configure.exe構成を使用して、CROSS_COMPILE=i 686-w 64-mingw 32-gmakeをコンパイルします。
方案二(未テスト):
./configure -no-fast -no-stl -no-opengl -no-openvg -no-webkit -no-script -no-scripttools -no-declarative -nomake examples -nomake tools -nomake demos -openssl -I /root/harrywu/build/3rd/ssl/include/ -L /root/harrywu/build/3rd/ssl/lib/ -xplatform win32-g++ -device-option CROSS_COMPILE=i686-w64-mingw32- && gmake && gmake install
最初に、構築システムは、ローカルコンパイラ(プレフィックスなしのg++)を呼び出して、いくつかのqmake関連の構築部品をコンパイルし、invokeがプレフィックス付きのクロスツールチェーンを開始し、Qtライブラリを構築する。(3)msvc 2008の設定スクリプトを添付します。
configure.exe ^
-release ^
-opensource ^
-confirm-license ^
-static ^
-no-ltcg ^
-no-fast ^
-exceptions ^
-accessibility ^
-stl ^
-no-sql-sqlite ^
-no-qt3support ^
-no-opengl ^
-no-openvg ^
-platform win32-msvc2008 ^
-no-system-proxies ^
-qt-zlib ^
-qt-libpng ^
-no-libmng ^
-no-libtiff ^
-qt-libjpeg ^
-no-dsp ^
-vcproj ^
-no-incredibuild-xge ^
-plugin-manifests ^
-qmake ^
-process -nomake demos -nomake examples ^
-no-rtti ^
-no-mmx ^
-no-3dnow ^
-no-sse ^
-no-sse2 ^
-no-dbus ^
-no-phonon -no-phonon-backend ^
-no-multimedia -no-audio-backend ^
-webkit ^
-script -scripttools -declarative ^
-arch windows ^
-no-style-plastique ^
-no-style-cleanlooks -no-style-cde ^
-no-style-motif ^
-no-native-gestures ^
-saveconfig csdnbuild