一、交叉编译qt
1、下载Qt源码包qt-everywhere-opensource-src-4.8.4.tar.gz;
地址:http://download.qt.io/archive/qt/
2、解压Qt源码包tar -zxvf qt-everywhere-opensource-src-4.8.4.tar.gz
3、创建qmake.conf
3.1在qt-everywhere-opensource-src-4.8.4/mkspecs/qws/下创建linux-hisiv500-g++文件夹;
3.2将qt-everywhere-opensource-src-4.8.4/mkspecs/qws/linux-arm-g++/下内容拷贝到3.1新建的文件夹中;
3.3 修改linux-hisiv500-g++/qmake.conf,如下
# 设置交叉编译工具链:
# 本项目使用的交叉编译工具是 arm-hisiv500-linux-g++
#
QMAKE_CC = arm-hisiv500-linux-gcc
QMAKE_CXX = arm-hisiv500-linux-g++
QMAKE_LINK = arm-hisiv500-linux-g++
QMAKE_LINK_SHLIB = arm-hisiv500-linux-g++
QMAKE_AR = arm-hisiv500-linux-ar cqs
QMAKE_OBJCOPY =arm-hisiv500-linux-objcopy
QMAKE_STRIP =arm-hisiv500-linux-strip
4、配置Qt编译选项
4..1 编译源码方式:
查看嵌入式QTE命令:./configure –embedded –help
通过进行裁剪得到下边配置参数:
进入Qt解压目录,执行如下命令:
./configure --prefix=/home/XX/qt4.8 -no-pch -xplatform qws/linux-hisiv500-g++ -arch arm -embedded arm -no-freetype -qt-mouse-pc -no-webkit -no-largefile -fast -release -no-qt3support -no-cups -no-opengl -no-phonon -phonon-backend -no-scripttools -no-libtiff -no-gif -no-libmng -no-nis -no-cups -no-svg -little-endian -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg
4.2 配置完毕输出如下内容:
Type 'c' if you want to use the Commercial Edition. //非开源
Type 'o' if you want to use the Open Source Edition.//开源
#o
This is the Qt for Embedded Linux Open Source Edition.
You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.
You are also licensed to use this software under the terms of
the GNU General Public License (GPL) versions 3.
Type '3' to view the GNU General Public License version 3.
Type 'L' to view the Lesser GNU General Public License version 2.1.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.
#yes
系统会根据.pro生成makefile文件。
5、make
6、sudo make intall
在/home/XX/qt4.8中生成目标库文件和qmake等
!!!!!!!!!!!!!!!说明!!!!!!!!!!!!!!!!!!
1、运行./configure -help ,查看我们需要设置那些选项。
-prefix 定义安装目录
挑几个来说一下:
//定义生成的是.so还是.a库
* -shared ............ Create and use shared Qt libraries.(默认)
-static ............ Create and use static Qt libraries.
//定义qt是否支持访问超过4GB的文件,看项目需求
-no-largefile ...... Disables large file support.(默认)
+ -largefile ......... Enables Qt to access files larger than 4 GB.
//定义是否编译STL。
-no-stl ............ Do not compile STL support.(默认)
* -stl ............... Compile STL support.
//是否编译浏览器内核模块
-no-webkit ......... Do not build the WebKit module.
+ -webkit ............ Build the WebKit module.
//是否支持编译OpenSSL
-no-openssl ........ Do not compile support for OpenSSL.
+ -openssl ........... Enable run-time OpenSSL support.
-openssl-linked .... Enabled linked OpenSSL support.
下面看嵌入式专属的配置
//目标平台
-xplatform target ... The target platform when cross-compiling.
// arm
-embedded <arch> .... This will enable the embedded build, you must have a
proper license for this switch to work.
Example values for <arch>: arm mips x86 generic
//CPU是大端还是小端 arm和x86 小端, mips大端。
-little-endian ...... Target platform is little endian (LSB first).
-big-endian ......... Target platform is big endian (MSB first).
// 是否字体库的设置
-no-freetype ........ Do not compile in Freetype2 support.
-qt-freetype ........ Use the libfreetype bundled with Qt.
参数-static 指的是要采用静态编译Qt的方法
参数-release指的是只编译release版本的库
参数-qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg 是更好确定Qt编译出的程序能在目前不知的系统下运行。
参数-nomake demos -nomake examples 指的是不编译demos和examples
参数-qt-sql-sqlite 如果没有这个参数,configure的时候,可能会提示sqlite 有问题而中止。
2、g++需要提前安装好,在Ubuntu系统可以使用apt -get 在线安装
3、参数-static 指的是要采用静态编译Qt的方法,qmake编译出的Qt程序就是采用静态编译的。这时你会发现,静态编译出来的程序大小变大了相当多。想编译一个程序,这个程序在发给别人后,他们可以直接打开,而不需要特别地去先安装Qt库,那就需要采用静态编译。