-
下载源码
地址:http://download.qt.io/archive/qt/5.6/5.6.3/single/
下载之后,解压到你喜欢的目录即可 -
修改qmake文件
进入目录/home/zhangsan/sourceCode_5.6.3/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/linux-arm-gnueabi-g++
打开qmake.conf,将编译器改成目标编译器
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a #指定处理器架构
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
QMAKE_CXX = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
QMAKE_LINK = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
# modifications to linux.conf
QMAKE_AR = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objcopy
QMAKE_NM = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm -P
QMAKE_STRIP = /home/zhangsan/sourceCode_5.6.3/gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip
load(qt_config)
- 配置configure选项,确定参数
这个选项因需求而异,网上有很多教程,不见得适用于每个人,我编译时就因为不懂犯了很多蠢错误,./configure --help ,先看看都有哪些参数,按需要配置,以下是我编译时配置的
sudo ./configure \
-prefix /opt/Qt5.6.3 \ //设置Qt安装的目录
-confirm-license \
-opensource \
-compile-examples \
-xplatform linux-arm-gnueabi-g++ \ //若不添加这个选项,默认编的是x86版本
-sysroot /opt/poky/1.7.3/sysroots/cortexa7hf-vfp-poky-linux-gnueabi \ //设置系统目录
-shared \
-release \ //我用的Ubuntu14.04,内存原因,故选择了较小的release版本
-optimized-qmake \
-opengl \
-pch \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-tslib \
-no-linuxfb \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-xcb \
-no-separate-debug-info \
-skip qtcanvas3d \ //skip 略过某模块,模块名即源码目录下的文件夹名
-skip qt3d \
-nomake examples \
-nomake tools \
-nomake tests \
-no-iconv
configure成功后会提示你使用make进行编译,make install进行安装,我编译的时候比较顺利,没有报错
-
make
命令:make -j4
这个阶段比较耗时,如果编译的模块多,可能需要几个小时,我编译的时候大概编译了两个小时,好在比较顺利,没有报错 -
make install
命令:make install -
配置QtCreator