Qt5.9.9交叉编译(带sqlite3、OpenSSL)

1、交叉编译工具链

      这里ARM平台是ARM CortexA9的,一般交叉编译工具链demo板厂商都会提供,若未提供或想更换新版本的交叉编译工具链可参考以下方式获取。

1.1 下载适用于ARM CortexA9的交叉编译工具链

Linaro Releases下载gcc4的最新版xxxx-i686_arm-linux-gnueabihf.tar.xz

1.2 配置交叉编译工具链

1.2.1 解压下载好的工具链包

$ tar xvf gcc-linaro-4.9.4-2017.01-i686_arm-linux-gnueabihf.tar.xz

1.2.2 部署并配置工具链

拷贝到系统路径

$ sudo mv gcc-linaro-4.9.4-2017.01-i686_arm-linux-gnueabihf /usr/local/arm-linux-gnueabihf

配置环境变量

$ vim ~/.bashrc

在文件末加入环境变量
export PATH=/usr/local/arm-linux-gnueabihf/bin:$PATH

使环境变量生效
$ source ~/.bashrc

检验工具链是否正常使用

$ arm-linux-gnueabihf-gcc -v

使用内建 specs。
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/local/arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/4.9.4/lto-wrapper
目标:arm-linux-gnueabihf
配置为:/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-4.9-2017.01/configure SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/i686-pc-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/i686-pc-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/i686-pc-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-objc-gc --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --with-float=hard --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/i686-pc-linux-gnu/arm-linux-gnueabihf/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-i386-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/i686-pc-linux-gnu
线程模型:posix
gcc 版本 4.9.4 (Linaro GCC 4.9-2017.01)

 2、SQLite交叉编译

    在后面交叉编译Qt源码的时候会用到

2.1 SQLite源码获取

SQLite Download Page下载最新版sqlite-autoconf-xxxx.tar.gz SQLite源码

2.2 交叉编码

解压源码
$ tar -xvf sqlite-autoconf-3360000.tar.gz

到源码路径
$ cd sqlite-autoconf-3360000/

配置编译
$ ./configure CC=arm-linux-gnueabihf-gcc --host=arm-linux --prefix=/opt/arm_sqlite

构建
$ make

安装
$ sudo make install

 3、OpenSSL交叉编译

    Qt使用SSL时需用到OpenSSL库。

3.1 下载OpenSSL源码

Releases · openssl/openssl · GitHub下载OpenSSL_1_x_x最新版的,因为Qt5.9只支持OpenSSL_1的环境,这里下载OpenSSL_1_1_1k 

3.2 交叉编译

解压
@ tar -xvf openssl-OpenSSL_1_1_1k.tar.gz

进入到源码路径
@ cd openssl-OpenSSL_1_1_1k/

配置为静态编译,注意这里的/home/xxx是当前用户路径,xxx代表当前用户名
@ ./config -fPIC no-shared no-asm --prefix=/home/xxx/arm_openssl --cross-compile-prefix=arm-linux-gnueabihf-

修改Makefile
@ vim Makefile

搜索并将-m64删除

编译
@ make -j4

安装
@ make install

4、Qt交叉编译

4.1 下载Qt5.9.9源码

https://download.qt.io/archive/qt/5.9/5.9.9/single/下载Qt5.9.9源码

4.2 配置编译
 

解压qt源码包
$ tar xvf qt-everywhere-opensource-src-5.9.9.tar.xz

进入到源码目录
$ cd qt-everywhere-opensource-src-5.9.9

4.2.1 配置qtbase/mkspecs/qmake.conf文件

#
# qmake configuration for building with arm-linux-gnueabihf-g++
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linuxfb #eglfs
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)

QMAKE_INCDIR += /opt/arm_sqlite/include   #已编译的sqlite头文件路径
QMAKE_LIBDIR += /opt/arm_sqlite/lib       #已编译的sqlite库路径

QMAKE_INCDIR += /home/wzl/arm_openssl/include   #已编译的openssl头文件路径
QMAKE_LIBDIR += /home/wzl/arm_openssl/lib       #已编译的openssl库路径

# modifications to g++.conf
QMAKE_CC                = arm-linux-gnueabihf-gcc
QMAKE_CXX               = arm-linux-gnueabihf-g++
QMAKE_LINK              = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB        = arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR                = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY           = arm-linux-gnueabihf-objcopy
QMAKE_NM                = arm-linux-gnueabihf-nm -P
QMAKE_STRIP             = arm-linux-gnueabihf-strip
load(qt_config)

4.2.1 编写构建脚本

$ vim build.sh

内容如下:
#!/bin/sh
./configure \
-v \
-prefix /home/wzl/workspace/Arm_Qt5.9.4 \
-release \
-opensource \
-no-accessibility \
-make libs \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-sqlite \
-qt-zlib \
-openssl-linked \
-no-sse2 \
-no-openssl \
-opengl es2 \
-no-cups \
-no-glib \
-no-iconv \
-no-pkg-config \
-no-separate-debug-info \
-skip qt3d \
-skip qtcanvas3d \
-skip qtdoc \
-skip qtwayland
exit

4.2.3 编译

配置执行权限
$ sudo chmod 777 build.sh

$ ./build.sh

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值