當前位置:編程學習大全網 - 編程語言 - 討論上Windows平臺怎麽編譯Qt5

討論上Windows平臺怎麽編譯Qt5

Qt5的編譯官方有壹篇wiki:/wiki/Building_Qt_5_from_Git

簡要的總結下我的體會,歡迎補充完善、批評指正。

1.First clone the top-level qt5 git repository:

git clone git://gitorious.org/qt/qt5.git qt5

這壹行不用說了,自然是將Qt5的代碼克隆。不過,如果妳只是初次克隆Qt5的代碼,會很驚訝:為何克隆後的代碼只有十幾MB?

原來,Qt5已經實現了Qt的模塊化,詳見:/2011/05/12/qt-modules-maturity-level-the-list/

所以可以在克隆得到的Qt5源碼根目錄下看到:.gitmodules 文件,其內容部分摘錄如下:

[submodule "qtbase"]

path = qtbase

url = git://gitorious.org/qt/qtbase.git

[submodule "qtsvg"]

path = qtsvg

url = git://gitorious.org/qt/qtsvg.git

[submodule "qtdeclarative"]

path = qtdeclarative

url = git://gitorious.org/qt/qtdeclarative.git

...

這時,有Git基礎的朋友壹定會想到:

git submodule init

git submodule update

不過,請不要這樣做!

2. Following the README file we initialize the repository. This clones the various sub-modules of Qt5:

./init-repository

這是壹個perl腳本。如果是在msys-git下,會發現Perl的版本不夠。

我們需要安裝壹個Windows版本的Perl:/activeperl/downloads

安裝好以後,Perl就添加到PATH環境變量中去了。

在MSVC的控制臺下執行:

perl init-repository --help

註意,不是直接執行init-repository,要用perl來執行它。看看幫助:大致了解下有哪些功能。

3. 註意它的三個小提示:

Hint1: If you’re going to contribute to Qt 5, you’ll need to pass the —codereview-username <Jira/Gerrit username> option to set up a “gerrit” remote for all the sub-modules.

Hint2: If you’re having problems downloading the webkit repository (which is quite big), you can pass —no-webkit.

Hint3: If you’re behind a firewall, pass —http

4. 我的方法:

perl init-repository -f --codereview-username loaden

這樣就可以實現子模塊的批處理了。特別要註意的是:在處理這些子模塊時,其實是git clone了這些子模塊,以致於他們可以獨立使用。在qt5\qtbase目錄下可以找到.git目錄。

這與git submodule update的結果是不壹樣的!!

同時我使用了codereview的用戶名,是為了可以創建壹個名為gerrit的遠程倉庫,可以將貢獻的代碼推送進去,類似:

git push gerrit HEAD:refs/for/master

5. 源碼下載是非常慢的,因為QtWebkit達到了1.7GB。源碼下載完成後,進入Qt5源碼目錄,配置環境變量:

set PATH=%CD%\qtbase\bin;%PATH%

之後echo看壹下結果是否正確:

echo %PATH%

6. 建議直接在Qt5的源碼目錄下執行配置!

configure -confirm-license -opensource -release -shared -platform win32-msvc2010 -fast -no-stl -no-qt3support -nomake examples -nomake demos -nomake tests

7. 編譯全部模塊,直接執行nmake就可以了。如果只編譯壹個模塊,可以這樣:

nmake module-qtbase

雙擊打開Qt5目錄下的Makefile文件,可以看到有這些模塊:

SUBTARGETS = \

module-qtbase \

module-qtsvg \

module-qtphonon \

module-qtxmlpatterns \

module-qtdeclarative \

module-qttools \

module-qttranslations \

module-qtdoc \

module-qlalr \

module-qtqa \

module-qtlocation \

module-qtactiveqt \

module-qtsensors \

module-qtsystems \

module-qtmultimedia \

module-qtfeedback \

module-qtquick3d \

module-qtdocgallery \

module-qtpim \

module-qtconnectivity \

module-qtwayland \

module-qtjsondb \

sub-qtwebkit-pri \

module-qtwebkit-examples-and-demos

  • 上一篇:數字示波器的特點有哪些
  • 下一篇:20世紀70年代興起的信息技術極大地改變了世界,其對軍事的影響有哪些方面,側重軍事國防
  • copyright 2024編程學習大全網