qt-5.6.0 移植之qt源码编译

 

其实这只是给自己看的一个configure选项笔记,没有太多的东西。

 

首先: 下载qt5.6的源码:

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

 

    下载完解压: tar  -xvf   qt-everywhere-opensource-src-5.6.0.tar.gz

 

    解压完进入源代码 : 修改几个东西:

      1. 进入qtbase/mkspecs 里面, 复制一份linux-arm-gnueabi-g++    ,名字为linux-arm

        在进入 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-

    可能你们的架构有可能是armv5 的, 交叉编译器可能是  arm-none-linux-gnueabi- 的,在这里提醒大家要注意了。

 

 

改完这些回到顶层目录,分析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

 

 

 

 

 

 

         

 

 

     

posted @ 2016-08-23 12:02  陈富林  阅读(21503)  评论(2编辑  收藏  举报