Qt 5 最小構建筆記(只編譯QtBase)

-skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquickcontrols -skip qtquickcontrols2 -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qttools -skip qttranslations -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns 

只想用Qt5最基本的功能,因此只編譯QtBase。也不想爲了編譯一個Qt裝很多東西
(比如非常肥的DirectX SDK)

軟件清單:

Visual Studio 2010 Professional with SP1
Active Perl
git Win32

步驟:

0 設置環境
開Visual Studio Command Prompt
把perl和git都放在PATH裏
檢查顯卡驅動是否支持OpenGL2.0以上
可以用這個工具:

https://sites.google.com/site/opengltutorialsbyaks/download/ex
tension-viewer

1 獲取repository:
git clone https://git.gitorious.org/qt/qt5.git qt5

2 獲取qtbase源代碼:
這一步不需要init-repository,直接去
http://qt.gitorious.org/qt/qtbase打包代碼並下載,
然後放在qtbase目錄下。

--- configure.exe
|
-- qtbase
      |- bin
      |- examples 
      |- ...

3 configure

>configure -confirm-license -opensource -release -shared -fast 
-nomake examples -nomake demos -nomake tests -opengl desktop

4 make

>nmake module-qtbase
所用時間差不多是 Qt4.8 的1/3

5 check

把 qtbase/bin 添加到PATH裏,編譯一些examples
--

   最近編譯出了Qt4.7.4的嵌入式版本,但沒有編譯QtWebkit庫。在編譯一個使用Webkit的工程時出錯,而根據工程的需要,要單獨編譯QtWebkit庫。
    由於不想再次編譯整個的Qt庫,於是進行了下面的嘗試,發現單獨編譯QtWebkit還是簡單的,當然其它模塊也是一樣的。

具體過程如下:

 

1.在qt源碼包的頂層運行configure配置:

------------------------------------------

./configure -opensource -confirm-license -release \
-prefix /usr/local/arm/qte4.7.4 \
-webkit -qt-zlib -no-script \
-xplatform qws/linux-arm-gnueabi-g++ -embedded armv6 \
-qt-kbd-linuxinput -qt-mouse-linuxinput -plugin-gfx-linuxfb \
-nomake demos -nomake examples -nomake tools -fast \
-L /usr/local/arm/lib -I /usr/local/arm/include

-----------------------------------------------------------

 

2.生成QtWebKit模塊的Makefile文件

進入QtWebKit源碼所在的目錄./src/3rdparty/webkit.如果在目錄中執行make會出錯,主要是qmake找不到,因爲在這時的Makefile文件中,使用的是固定路徑的qmake.
使用以下命令重生成Makefile文件,當然後面的spec路徑要根據實際情形設置

 

qmake WebKit.pro -r -spec /usr/local/arm/qte4.7.4/mkspecs/qws/linux-arm-gnueabi-g++

 

3.編譯
make

編譯過程中仍出現錯誤:
-----------------------------------------------------------------------------------------
......

正在進入目錄 `/home/dragon/project/qte4.7.4/src/3rdparty/webkit/WebKit/qt/tests/qwebframe'
然後一堆類似這樣的錯誤
../../Api/qwebframe.cpp:21:20: error: config.h: No such file or directory
../../Api/qwebframe.cpp:24:20: error: Bridge.h: No such file or directory
../../Api/qwebframe.cpp:25:23: error: CallFrame.h: No such file or directory
../../Api/qwebframe.cpp:26:22: error: Document.h: No such file or directory
../../Api/qwebframe.cpp:27:28: error: DocumentLoader.h: No such file or directory

......
-----------------------------------------------------------------------------------------
看來忘加-nomake test選項了,但幸好QtWebKit庫己編譯出來,就不去處理這些錯誤了。後來經過試驗,加上-nomake test編譯就不會出現錯誤了。

 

4.安裝
make install

再到安裝目錄中檢查,libQtWebKit.so.4.7.4庫己經安裝

 

5.測試
使用現在的QtEmbedded來編譯一個使用QtWebKit的工程browser,在make過程中出錯:
------------------------------------------------------------------------------------------
In file included from /usr/local/arm/qte4.7.4/include/QtWebKit/QWebFrame:1,
                 from browsermainwindow.cpp:70:
/usr/local/arm/qte4.7.4/include/QtWebKit/qwebframe.h:28:36: error: QtScript/qscriptengine.h: No such file or directory
In file included from /usr/local/arm/qte4.7.4/include/QtWebKit/QWebFrame:1,
                 from browsermainwindow.cpp:70:

------------------------------------------------------------------------------------------

看來QtWebKit依賴QtScript,只好再編譯QtScript

下面是單獨編譯QtScript模塊的過程
這次confiugre的參數配置如下:

------------------------------------------------------------

./configure -opensource -confirm-license -release \
-prefix /usr/local/arm/qte4.7.4 \
-webkit -qt-zlib \
-xplatform qws/linux-arm-gnueabi-g++ -embedded armv6 \
-qt-kbd-linuxinput -qt-mouse-linuxinput -plugin-gfx-linuxfb \
-nomake demos -nomake examples -nomake tools -nomake test -fast \
-L /usr/local/arm/lib -I /usr/local/arm/include

------------------------------------------------------------

與上次配置不同的是去掉了-no-script選項,增加了-nomake test選項

 

然後進入./src/script目錄
qmake script.pro -r -spec /usr/local/arm/qte4.7.4/mkspecs/qws/linux-arm-gnueabi-g++

make

make install

現在再次編譯browser工程,終於順利地單獨編譯出QtWebKit庫。並使用一個工程進行了測試,一切都正常。


    從上面的過程可以看出,Qt庫的許多模塊可以單獨編譯的。只要先使用configure配置選上需要的模塊,注意帶上-fast選項和適當的-nomake選項;然後進到相應的模塊源碼目錄中,使用qmake重新生成對應的Makfile文件;在此目錄make、make install。如此這般就完成了Qt模塊的單獨編譯.

    有人可能會問,爲什麼要單獨編譯。當然可以一次就搞定所有模塊,不過交叉編譯往往由於各種原因,某些模塊編譯通不過,有時有些模塊肯定用不到,總有一些原因造成Qt的模塊編譯不完整。在這時,不需要再次編譯所有的Qt庫,只要單獨編譯就可以的。何樂而不爲Qt4.7.4下單獨編譯QtWebkit

 

https://www.cnblogs.com/findumars/p/6375973.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章