1. 起源

目标平台为arm架构,无x64或windows安装包

http://download.qt-project.org/archive/qt/5.9/5.9.8/

交叉编译Qt5.9.8_g++

 

 

 2. 下载qt-everywhere

http://download.qt-project.org/archive/qt/5.9/5.9.8/single/

交叉编译Qt5.9.8_linux_02

 

 

tar.xz,这是两层压缩,外面是xz压缩,里层是tar压缩,所以分两步实现解压。



# xz -d qt-everywhere-opensource-src-5.9.8.tar.xz
# tar -xvf qt-everywhere-opensource-src-5.9.8.tar.xz

也可以直接解压
# tar -xvJf qt-everywhere-opensource-src-5.9.8.tar.xz


 解压完成

交叉编译Qt5.9.8_unix_03

 

3. linux - arm 交叉编译器

交叉编译Qt5.9.8_linux_04

 

 

3.1 ​​vim ./qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf #编辑qmake.conf​

交叉编译Qt5.9.8_g++_05

 



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

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linuxfb #指定Qt显示驱动方式
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/tslib/include /opt/sqlite3/include #指定头文件,需预编译
QMAKE_LIBDIR += /opt/tslib/lib /opt/sqlite3/lib #指定库文件,需预编译


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

# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy
QMAKE_NM = arm-linux-gnueabi-nm -P
QMAKE_STRIP = arm-linux-gnueabi-strip

load(qt_config)
~


 

3.2 问题:make:g++:命令未找到

sudo apt-get install g++

 

3.3 configure编译配置

报错1

Qt5.5.1 configure编译选项,在这里不再介绍。

配置生成make文件时不报错,就可以make了。



$ cd qt-everywhere-opensource-src-5.5.1/
$ sudo ./configure \
-prefix /opt/qte5.5.1 \
-confirm-license \
-opensource \
-shared \
-release \
-make libs \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-qt-sql-sqlite \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-no-opengl \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-dbus \
-no-xcb \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-no-fontconfig \
-nomake examples -nomake tools -nomake tests -no-iconv \
-tslib \
-I/opt/tslib/include \
-L/opt/tslib/lib


交叉编译Qt5.9.8_sqlite_06

 

交叉编译Qt5.9.8_.net_07

 

ERROR: Invalid value given for boolean command line option 'sql-sqlite'.

ERROR: Unknown command line option '-no-xcursor'.


修改后



sudo ./configure \
-prefix /opt/qte5.5.1 \
-confirm-license \
-opensource \
-shared \
-release \
-make libs \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-no-opengl \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-dbus \
-no-xcb \
-no-separate-debug-info \
-no-fontconfig \
-nomake examples -nomake tools -nomake tests -no-iconv \
-tslib \
-I/opt/tslib/include \
-L/opt/tslib/lib


报错2

交叉编译Qt5.9.8_sqlite_08

 

 arm-linux-gnueabi-g++

 ==>

sudo apt-get  install gcc-arm-linux-gnueabi

sudo apt-get install g++-arm-linux-gnueabi

 交叉编译Qt5.9.8_sqlite_09

 报错3

交叉编译Qt5.9.8_sqlite_10

 

 交叉编译Qt5.9.8_linux_11

 

 

ERROR: Feature 'tslib' was enabled, but the pre-condition 'libs.tslib' failed.

交叉编译Qt5.9.8_unix_12

 

ERROR: Feature 'tslib' was enabled, but the pre-condition 'libs.tslib' failed.

ERROR: Feature 'system-sqlite' was enabled, but the pre-condition 'libs.sqlite3' failed.


解决:tslib和sqlite3要预先编译并指定路径或者配置末尾加上-recheck-all选项。