qt-5.6.0 移植之qt源碼編譯

 

其實這只是給本身看的一個configure選項筆記,沒有太多的東西。mysql

 

首先: 下載qt5.6的源碼:linux

    地址: http://download.qt.io/archive/qt/5.6/c++

 

    下載完解壓: tar  -xvf   qt-everywhere-opensource-src-5.6.0.tar.gz正則表達式

 

    解壓完進入源代碼 : 修改幾個東西:sql

      1. 進入qtbase/mkspecs 裏面, 複製一份linux-arm-gnueabi-g++    ,名字爲linux-armapi

        在進入 linux-arm 裏面, vi  qmake.conf , 把裏面的代碼改成本身平臺架構以及本身交叉編譯器,個人更改以下:架構

 1 #                                                                               
 2 # qmake configuration for building with arm-linux-gnueabi-g++                   
 3 #                                                                               
 4                                                                                 
 5 MAKEFILE_GENERATOR      = UNIX                                                  
 6 CONFIG                 += incremental                                           
 7 QMAKE_INCREMENTAL_STYLE = sublib                                                
 8                                                                                 
 9 QT_QPA_DEFAULT_PLATFORM = linuxfb                                               
10 QMAKE_CFLAGS_RELEASE   += -O2 -march=armv7-a                                    
11 QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a                                    
12                                                                                 
13 QMAKE_INCDIR += $(TSLIB)/include                                                
14 QMAKE_LIBDIR += $(TSLIB)/lib                                                    
15                                                                                 
16 include(../common/linux.conf)                                                   
17 include(../common/gcc-base-unix.conf)                                           
18 include(../common/g++-unix.conf)                                                
19                                                                                 
20 # modifications to g++.conf                                                     
21 QMAKE_CC                = arm-arago-linux-gnueabi-gcc                           
22 QMAKE_CXX               = arm-arago-linux-gnueabi-g++                           
23 QMAKE_LINK              = arm-arago-linux-gnueabi-g++                           
24 QMAKE_LINK_SHLIB        = arm-arago-linux-gnueabi-g++                           
25 # modifications to linux.conf                                                   
26 QMAKE_AR                = arm-arago-linux-gnueabi-ar cqs                        
27 QMAKE_OBJCOPY           = arm-arago-linux-gnueabi-objcopy                       
28 QMAKE_NM                = arm-arago-linux-gnueabi-nm -P                         
29 QMAKE_STRIP             = arm-arago-linux-gnueabi-strip                         
30 load(qt_config)                                                                 
31 ~                                                                                     

 

    個人架構是armv7-a , 個人交叉編譯器的前綴是  arm-arago-linux-gnueabi-less

    可能大家的架構有多是armv5 的, 交叉編譯器多是  arm-none-linux-gnueabi- 的,在這裏提醒你們要注意了。ide

 

 

改完這些回到頂層目錄,分析configure  的選項。我今天準備一個個分析。工具

在qt5.6 源碼頂層目錄下 , 敲: ./configure --help , 它就會把全部的configure的選項都羅列出來:

 

下面來一個個分析:

  

    -prefix <dir> ...... The deployment directory, as seen on the target device.
                         (default /usr/local/Qt-5.6.0, $PWD if -developer-build is active) 

    第一個參數: -prefix <dir> 這個指定 make 完成後make install 的目錄,不指定的話默認是/usr/local/Qt-5.6.0

 

    -extprefix <dir> ... The installation directory, as seen on the host machine.
                         (default SYSROOT/PREFIX)                               
     -hostprefix [dir] .. The installation directory for build tools running on the 
                         host machine. If [dir] is not given, the current build 
                         directory will be used. (default EXTPREFIX)  

    這兩個參數就沒有什麼好介紹的了, 一個是若是指定了sysroot 目錄, 他會去安裝了sysroot/$PREFIX 目錄下,一個是直接安裝到$EXTPREFIX目錄。

 You may use these to change the layout of the install. Note that all directories
 except -sysconfdir should be located under -prefix/-hostprefix:                
                                                                                
    -bindir <dir> ......... User executables will be installed to <dir>         
                            (default PREFIX/bin)                                
    -headerdir <dir> ...... Headers will be installed to <dir>                  
                            (default PREFIX/include)                            
    -libdir <dir> ......... Libraries will be installed to <dir>                
                            (default PREFIX/lib)                                
    -archdatadir <dir> .... Arch-dependent data used by Qt will be installed to <dir>
                            (default PREFIX)                                    
    -plugindir <dir> ...... Plugins will be installed to <dir>                  
                            (default ARCHDATADIR/plugins)                       
    -libexecdir <dir> ..... Program executables will be installed to <dir>      
                            (default ARCHDATADIR/libexec, ARCHDATADIR/bin for MinGW)
    -importdir <dir> ...... Imports for QML1 will be installed to <dir>         
                            (default ARCHDATADIR/imports)                       
    -qmldir <dir> ......... Imports for QML2 will be installed to <dir>         
                            (default ARCHDATADIR/qml)                           
    -datadir <dir> ........ Arch-independent data used by Qt will be installed to <dir>
                            (default PREFIX)                                    
    -docdir <dir> ......... Documentation will be installed to <dir>            
                            (default DATADIR/doc)                               
    -translationdir <dir> . Translations of Qt programs will be installed to <dir>
                            (default DATADIR/translations)                      
    -sysconfdir <dir> ..... Settings used by Qt programs will be looked for in <dir>
                            (default PREFIX/etc/xdg)                            
    -examplesdir <dir> .... Examples will be installed to <dir>                 
                            (default PREFIX/examples)                           
    -testsdir <dir> ....... Tests will be installed to <dir>                    
                            (default PREFIX/tests)                              
                                                                                
    -hostbindir <dir> .. Host executables will be installed to <dir>            
                         (default HOSTPREFIX/bin)                               
    -hostlibdir <dir> .. Host libraries will be installed to <dir>              
                         (default HOSTPREFIX/lib)                               
    -hostdatadir <dir> . Data used by qmake will be installed to <dir>          
                         (default HOSTPREFIX)                                   

    這些選項的話是能夠改變你的你的全部子目錄的安裝目錄。 好比說Qt-5.6.0/bin 的安裝目錄或是其實的一些目錄

 

 

    下面是一些配置選項:

*   -release ........... Compile and link Qt with debugging turned off.         
    -debug ............. Compile and link Qt with debugging turned on.          
    -debug-and-release . Compile and link two versions of Qt, with and without  
                         debugging turned on (Mac only).                        
                                                                                
    -force-debug-info .. Create symbol files for release builds.                
                                                                                
    -developer-build ... Compile and link Qt with Qt developer options (including auto-tests exporting)

    第一個,--release  編譯以及連接qt  可是關閉調試。通常的話交叉編譯qt的源碼都選擇這個選項。

        -debug , 開啓調試的接口

        -debug-and-release 編譯成上面連個版本。

        -force-debug-info 建立字符文件爲了記錄版本(不知道是否是正確,沒有驗證過)。

        -developer-build  編譯和連接qt 並且加入開發者選項(包含本身測試輸出)。

 

 

 *  -no-optimized-tools ... Do not build optimized host tools even in debug build.
    -optimized-tools ...... Build optimized host tools even in debug build.     
                                                                                
    -opensource ........ Compile and link the Open-Source Edition of Qt.        
    -commercial ........ Compile and link the Commercial Edition of Qt.         
                                                                                
    -confirm-license ... Automatically acknowledge the license (use with        
                         either -opensource or -commercial)                     
                                                                                
    -c++std <edition> .. Compile Qt with C++ standard edition (c++98, c++11, c++14, c++1z)
                         Default: highest supported                             
                                                                                

        前面兩個是 是否要創建優化主工具當調試的時候,通常我會選擇 -no-optimized-tools

        -opensource  編譯和連接開源QT版本,通常的話咱們都是使用的開源的QT版本。

        -commercial  編譯和連接商業QT版本。

        -onfirm-license 自動確認是不是開源仍是商業的。

        -c++std <>  編譯QT 是使用的什麼版本的c++ ,默認爲最高版本

   

 

 *  -shared ............ Create and use shared Qt libraries.                    
    -static ............ Create and use static Qt libraries.                    
                                                                                
    -no-largefile ...... Disables large file support.                           
 +  -largefile ......... Enables Qt to access files larger than 4 GB.           
                                                                                
    -no-accessibility .. Do not compile Accessibility support.                  
                         Disabling accessibility is not recommended, as it will break QStyle
                         and may break other internal parts of Qt.              
                         With this switch you create a source incompatible version of Qt,
                         which is unsupported.                                  
 +  -accessibility ..... Compile Accessibility support.                         
                                                                                
    -no-sql-<driver> ... Disable SQL <driver> entirely.                         
    -qt-sql-<driver> ... Enable a SQL <driver> in the Qt SQL module, by default 
                         none are turned on.                                    

        第一個比較容易理解: 是編譯成動態庫仍是靜態庫,通常的話咱們編譯的都是動態庫,這樣的話軟件的大小不會那麼大, 選擇的是 -shared

        第二個是是否容許大文件支持, 這個我還沒沒有試過。 通常我選擇的都是默認的,默認是 -largefile

        第三個是易接近支持, 由於不一樣版本的qt都作了一些相關的改動, 通常的話我都選擇默認, 這樣的話能夠提升軟件的可移植性。 -accessibility

        第四個是SQL 驅動模塊的指定。我這裏是沒有這個模塊的驅動的,因此我不去指定這個選項通常

 

 

 

    -plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to        
                         at run time.                                           
                                                                                
                         Possible values for <driver>:                          
                         [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ]   
                                                                                
    -system-sqlite ..... Use sqlite from the operating system.                  
                                                                                
    -no-qml-debug ...... Do not build the in-process QML debugging support.     
 +  -qml-debug ......... Build the QML debugging support.                       
                                                                                
    -platform target ... The operating system and compiler you are building     
                         on (default detected from host system).                
                                                                                
                         See the README file for a list of supported            
                         operating systems and compilers.                       
                                                                                

 

         前面兩個仍是關於sql 的。一個容許sql做爲一個插件在運行的時候,一個使用系統的sqlite 

         下面那個是指定是否編譯QML 調試支持, 通常我選擇的是:-no-qml-debug

         第三塊是選擇目標平臺:默認是選擇本機的操做系統, 閱讀頂層目錄的readme 能夠知道支持哪些操做系統。

 

 

   -no-sse2 ........... Do not compile with use of SSE2 instructions.          
    -no-sse3 ........... Do not compile with use of SSE3 instructions.          
    -no-ssse3 .......... Do not compile with use of SSSE3 instructions.         
    -no-sse4.1 ......... Do not compile with use of SSE4.1 instructions.        
    -no-sse4.2 ......... Do not compile with use of SSE4.2 instructions.        
    -no-avx ............ Do not compile with use of AVX instructions.           
    -no-avx2 ........... Do not compile with use of AVX2 instructions.          
    -no-mips_dsp ....... Do not compile with use of MIPS DSP instructions.      
    -no-mips_dspr2 ..... Do not compile with use of MIPS DSP rev2 instructions. 

        這些選項我都沒有研究過是幹嗎的。因此我通常我不指定他

 

    -qtnamespace <name>  Wraps all Qt library code in 'namespace <name> {...}'. 
    -qtlibinfix <infix>  Renames all libQt*.so to libQt*<infix>.so.             
                                                                                
    -testcocoon ........ Instrument Qt with the TestCocoon code coverage tool.  
    -gcov .............. Instrument Qt with the GCov code coverage tool.        
                                                                                
    -D <string> ........ Add an explicit define to the preprocessor.            
    -I <string> ........ Add an explicit include path.                          
    -L <string> ........ Add an explicit library path.                          

        第一個是qt命名空間的, 通常不修改。

        第二個是對qt庫的重命名,加一些後綴。通常咱們也用不到。

        第三第四個是關於testcocoon 和 GCov的工具,通常我也不會去指定

        後面三個第一個是 在預處理的時候加一個前綴,第二個是添加一個額外的頭文件目錄,第三個是添加一個額外的庫目錄

 

 

 +  -pkg-config ........ Use pkg-config to detect include and library paths. By default,
                         configure determines whether to use pkg-config or not with
                         some heuristics such as checking the environment variables.
    -no-pkg-config ..... Disable use of pkg-config.                             
    -force-pkg-config .. Force usage of pkg-config (skips pkg-config usability  
                         detection heuristic).                                  
                                                                                
    -help, -h .......... Display this information.                              
                                                                                

         第一個是指定是否支持pkg-config  它回去尋找屬於你的頭文件以及庫,後面還有一個強迫使用,意思就是必須使用。

         第二個是打印幫助。

         

 

下面是第三方庫的問題。這個東西至關的麻煩,說句實話,我就是由於這個問題停在這裏兩天了。因此我纔來跟一下這個配置選項,看一下是否是個人配置出了問題

 

Third Party Libraries:                                                          
                                                                                
    -qt-zlib ............ Use the zlib bundled with Qt.                         
 +  -system-zlib ........ Use zlib from the operating system.                   
                          See http://www.gzip.org/zlib                          
                                                                                
    -no-mtdev ........... Do not compile mtdev support.                         
 +  -mtdev .............. Enable mtdev support.                                 
                                                                                
 +  -no-journald ........ Do not send logging output to journald.               
    -journald ........... Send logging output to journald.                      
                                                                                
 +  -no-syslog .......... Do not send logging output to syslog.                 
    -syslog ............. Send logging output to syslog.                        
                                                                                
    -no-gif ............. Do not compile GIF reading support.                   
                                                                                
    -no-libpng .......... Do not compile PNG support.                           
    -qt-libpng .......... Use the libpng bundled with Qt.                       
 +  -system-libpng ...... Use libpng from the operating system.                 
                          See http://www.libpng.org/pub/png                     
                                                                                
    -no-libjpeg ......... Do not compile JPEG support.                          
    -qt-libjpeg ......... Use the libjpeg bundled with Qt.                      
 +  -system-libjpeg ..... Use libjpeg from the operating system.                
                          See http://www.ijg.org                                

      第一個是zlib 庫, 默認是系統的zlib , 可是咱們要選 -qt-zlib ,不要問我爲何, 由於我如今是在作移植,系統的是X86架構的,板子不同。

      第二個是mtdev 支持, 是觸摸屏多點控制協議的支持。若是你的觸摸屏要多點控制,那就加上。 -medev.

      第三個是輸入日誌支持,有必要的話能夠加上。 -syslog , 通常的話我選擇默認。

      第四個是指定沒有gif 閱讀功能 , 我都不須要這個功能, 因此我會加上 -no-gif。

      第五個是指定是否支持PNG 這個我通常也是會加上 -no-libpng , 或者是-qt-libpng。

      第六個是指定jpeg 庫支持, 和上面那個同理,-no-libjpeg或者是 -qt-libjpeg。

 

 

    -no-freetype ........ Do not compile in Freetype2 support.                  
    -qt-freetype ........ Use the libfreetype bundled with Qt.                  
 +  -system-freetype..... Use the libfreetype provided by the system (enabled if -fontconfig is active).
                          See http://www.freetype.org                           
                                                                                
    -no-harfbuzz ........ Do not compile HarfBuzz-NG support.                   
 *  -qt-harfbuzz ........ Use HarfBuzz-NG bundled with Qt to do text shaping.   
                          It can still be disabled by setting                   
                          the QT_HARFBUZZ environment variable to "old".        
    -system-harfbuzz .... Use HarfBuzz-NG from the operating system             
                          to do text shaping. It can still be disabled          
                          by setting the QT_HARFBUZZ environment variable to "old".
                          See http://www.harfbuzz.org                           
                                                                                
    -no-openssl ......... Do not compile support for OpenSSL.                   
 +  -openssl ............ Enable run-time OpenSSL support.                      
    -openssl-linked ..... Enabled linked OpenSSL support.                       
                                                                                
    -no-libproxy ....... Do not compile support for libproxy                    
 +  -libproxy .......... Use libproxy from the operating system.                

       第一個是 freetype2 的編譯支持。 通常我會選擇-no-freetype 或者是-qt-freetype . 原則是隻要是有關操做系統,最好不要有system 字眼。

       第二個是有關字體的。通常我會選擇-qt-harfbuzz.

       第三個是 openssl ,通常我會選擇-no-openssl 。

       第四個是 proxy , 最好不要搭上本機操做系統 , -no-libproxy

 

 

    -qt-pcre ............ Use the PCRE library bundled with Qt.                 
 +  -system-pcre ........ Use the PCRE library from the operating system.       
                                                                                
    -qt-xcb ............. Use xcb- libraries bundled with Qt.                   
                          (libxcb.so will still be used from operating system). 
 +  -system-xcb ......... Use xcb- libraries from the operating system.         
                                                                                
    -xkb-config-root .... Set default XKB config root. This option is used only together with -qt-xkbcommon-x11.
    -qt-xkbcommon-x11 ... Use the xkbcommon library bundled with Qt in combination with xcb.
 +  -system-xkbcommon-x11 Use the xkbcommon library from the operating system in combination with xcb.
                                                                                
    -no-xkbcommon-evdev . Do not use X-less xkbcommon when compiling libinput support.
 *  -xkbcommon-evdev .... Use X-less xkbcommon when compiling libinput support. 

        pcre 是一個c語言編寫的正則表達式庫,這裏的話能夠不指定。

        xcb  這裏的話我指定的是qt-xcb

        xkb  這裏的話我沒去搭理他,

 

 

    -no-xinput2 ......... Do not compile XInput2 support.                       
 *  -xinput2 ............ Compile XInput2 support.                              
                                                                                
    -no-xcb-xlib......... Do not compile Xcb-Xlib support.                      
 *  -xcb-xlib............ Compile Xcb-Xlib support.                             
                                                                                
    -no-glib ............ Do not compile Glib support.                          
 +  -glib ............... Compile Glib support.                                 
                                                                                
    -no-pulseaudio ...... Do not compile PulseAudio support.                    
 +  -pulseaudio ......... Compile PulseAudio support.                           
                                                                                
    -no-alsa ............ Do not compile ALSA support.                          
 +  -alsa ............... Compile ALSA support.                                 
                                                                                
    -no-gtkstyle ........ Do not compile GTK theme support.                     
 +  -gtkstyle ........... Compile GTK theme support.       

        xinput2 是關乎多點觸摸的, 如今我尚未用到,因此我忽略了他。

        xcb-xlib 我也沒有去管他。

        glib 我是直接給了 -no-glib

        pulseaudio 這是關於聲音系統的。我給了是默認

        alsa  這是音頻子系統的支持。 也是默認就好了。

        gtkstype  GTK 主題支持,這個仍是算了吧,我只求能移植成功,功能不要太炫。

 

 

 

下面是一些另外的選項了

Additional options:                                                             
                                                                                
    -make <part> ....... Add part to the list of parts to be built at make time.
                         (defaults to: libs tools examples)                     
    -nomake <part> ..... Exclude part from the list of parts to be built.       
                                                                                
    -skip <module> ..... Exclude an entire module from the build.               
                                                                                
    -no-compile-examples ... Install only the sources of examples.              
                                                                                
    -no-gui ............ Don't build the Qt GUI module and dependencies.        
 +  -gui ............... Build the Qt GUI module and dependencies.              
                                                                                
    -no-widgets ........ Don't build the Qt Widgets module and dependencies.    
 +  -widgets ........... Build the Qt Widgets module and dependencies.          

        第一個是讓你選擇要不要編譯某些另外的模塊, 好比說libs , tools , examples .我如今是把全部的加上,由於移植進去了就能夠直接用 examples裏面的程序執行看一下是否移植成功。

        第二項是 gui 支持,我直接加上吧。

        第三個 widgets 也是差很少,也是直接上了。

        

    -R <string> ........ Add an explicit runtime library path to the Qt         
                         libraries.                                             
    -l <string> ........ Add an explicit library.                               
                                                                                
    -no-rpath .......... Do not use the library install path as a runtime       
                         library path. On Apple platforms, this implies using   
                         absolute install names (based in -libdir) for dynamic  
                         libraries and frameworks.                              
 +  -rpath ............. Link Qt libraries and executables using the library    
                         install path as a runtime library path. Equivalent     
                         to -R install_libpath                                  
                                                                                
    -continue .......... Continue as far as possible if an error occurs.        
                                                                                
    -verbose, -v ....... Print verbose information about each step of the       
                         configure process.                                     
                                                                                
    -silent ............ Reduce the build output so that warnings and errors    
                         can be seen more easily.                               
                                                                                

        第一項是添加一個庫在Qt程序執行時,這個我無論我選默認。

        第二項是添加一個庫

        我通常給這個rpath 給默認值。

        -continue 是指定若是出現某個錯誤指令繼續的命令。

        -v 是指打印詳細的信息關於每一個配置程序。

        -silent 是指定減小輸出的信息,這樣的話查找錯誤就更容易。

 

 

 

    -no-cups ........... Do not compile CUPS support.                           
 *  -cups .............. Compile CUPS support.                                  
                         Requires cups/cups.h and libcups.so.2.                 
                                                                                
    -no-iconv .......... Do not compile support for iconv(3).                   
 *  -iconv ............. Compile support for iconv(3).                          
                                                                                
    -no-evdev .......... Do not compile support for evdev.                      
 *  -evdev ............. Compile support for evdev.                             
                                                                                
    -no-tslib .......... Do not compile support for tslib.                      
 *  -tslib ............. Compile support for tslib.                             
                                                                                
    -no-icu ............ Do not compile support for ICU libraries.              
 +  -icu ............... Compile support for ICU libraries.                     

        -cups  是打印管理的一個支持, 通常的話選擇默認就好。

        -iconv  這是文本編碼轉化功能,這個網上有些教程說應該去掉這個功能  因此選擇 -no-iconv, 目前尚未試驗。

        -evdev  這個選擇默認就行。

        -tslib     這個是觸摸屏矯正的一個功能。這個仍是要加上。

        -icu   這個選項仍是選擇默認。

 

    -no-linuxfb ........ Do not compile Linux Framebuffer support.              
 *  -linuxfb ........... Compile Linux Framebuffer support.                     


    -no-opengl .......... Do not support OpenGL.                                
    -opengl <api> ....... Enable OpenGL support                                 
                          With no parameter, this will attempt to auto-detect   
                          OpenGL ES 2.0 and higher, or regular desktop OpenGL.  
                          Use es2 for <api> to override auto-detection.         

        這連個選項, 使用linuxfb 的支持已經忽略opengl 

        -linux     -no-opengl

 

 1 #!/bin/sh                                                                       
 2                                                                                 
 3                                                                                 
 4 ./configure \                                                                   
 5         -prefix /home/desk/7109/qtsrc/qt-src \                                  
 6         -confirm-license \                                                      
 7         -opensource \                                                           
 8         -release  \                                                             
 9         -make libs \                                                            
10         -xplatform linux-arm \                                                  
11         -optimized-qmake \                                                      
12         -linuxfb    \                                                           
13         -pch \                                                                  
14         -qt-sql-sqlite \                                                        
15         -qt-libjpeg \                                                           
16         -qt-libpng \                                                            
17         -qt-zlib \                                                              
18         -tslib \                                                                
19         -no-opengl \                                                            
20         -no-sse2 \                                                              
21         -no-openssl \                                                           
22         -no-nis \                                                               
23         -no-cups \                                                              
24         -no-glib \                                                              
25         -no-dbus \                                                              
26         -no-xcb \                                                               
27         -no-xcursor -no-xfixes -no-xrandr -no-xrender \                         
28         -no-separate-debug-info \                                               
29         -make examples -nomake tools -nomake tests -no-iconv                    
30                                                                               

 

 

而後, make -j4

sudo make install

相關文章
相關標籤/搜索