准备工作
下载软件
- 下载相应的触摸屏库
tslib
- 下载
linaro
交叉编译工具链:Linaro Releases - 下载QT源码:Index of /archive/qt/5.9/5.9.6/single
文件名 | 说明 |
---|---|
gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.bz2 | 交叉编译工具链 |
tslib.tar.bz2 | 触摸屏库 |
qt-everywhere-opensource-src-5.9.6.tar.xz | qt5.9.6源码 |
环境搭建
将
gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.bz2
和tslib.tar.bz2
移动到/opt
目录下解压
gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.bz2
到opt目录1
2cd /opt
sudo tar -xvjf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.bz2解压
tslib.tar.bz2
到opt目录1
2cd /opt
sudo tar -xvjf tslib.tar.bz2测试交叉编译链
1
2cd /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin
./arm-linux-gnueabihf-g++ -v如果不能运行,可能是系统版本64位与交叉编译链32位不符导致,可以安装32位支持:
1
2
3sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 -y
配置与编译QT
将
qt-everywhere-opensource-src-5.9.6.tar.xz
移动到用户目录下,创建qt-5.9.6-source
目录用于放源码1
2cd ~
mkdir qt-5.9.6-source解压
qt-everywhere-opensource-src-5.9.6.tar.xz
到用户目录1
tar -xvjf qt-everywhere-opensource-src-5.9.6.tar.xz ./qt-5.9.6-source
配置交叉编译链
- 打开配置文件
1
2cd ~/qt-5.9.6-source/qt-everywhere-opensource-src-5.9.6
vi ./qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf- 修改内容,并指定交叉编译链地址
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS += -march=armv7-a -mtune=cortex-a7
QMAKE_CXXFLAGS += -march=armv7-a -mtune=cortex-a7
QMAKE_INCDIR = /opt/tslib/include
QMAKE_LIBDIR = /opt/tslib/lib
# modifications to g++.conf
QMAKE_CC = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-gcc -lts
QMAKE_CXX = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++ -lts
QMAKE_LINK = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++ -lts
QMAKE_LINK_SHLIB = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++ -lts
# modifications to linux.conf
QMAKE_AR = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-objcopy
QMAKE_NM = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-nm -P
QMAKE_STRIP = /opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-strip
load(qt_config)创建
autoConfig.sh
文件1
vi ~/qt-5.9.6-source/qt-everywhere-opensource-src-5.9.6/autoConfig.sh
autoConfig.sh
内容:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#!/bin/sh
./configure \
-prefix /opt/qt-5.9.6 \
-v \
-confirm-license \
-opensource \
-release \
-make libs \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-qt-libjpeg \
-qt-libpng \
-qt-zlib -tslib \
-no-opengl -no-sse2 -no-openssl -no-cups -no-glib -no-xcb \
-no-separate-debug-info -nomake examples \
-nomake tools -nomake tests -no-iconv -no-dbus \
-I /opt/tslib/include \
-L /opt/tslib/lib \
-recheck-all编译QT
1
./autoConfig.sh && make -j4 && make install
编译后的qt库放置与/opt目录下