【TINY4412】QT5移植笔记:(3)QT5.6移植到Linux
阅读原文时间:2021年04月24日阅读:1

【TINY4412】QT5移植笔记:(3)QT5.6移植到Linux

宿主机 : 虚拟机 Ubuntu 16.04 LTS / X64
目标板[底板]: Tiny4412SDK - 1506
目标板[核心板]: Tiny4412 - 1412
LINUX内核: 4.12.0
交叉编译器: arm-none-linux-gnueabi-gcc(gcc version 4.8.3 20140320)
日期: 2017-10-2 09:31:07
作者: SY

简介

5.6 版本和 5.7 版本还是有些不同,参考 5.7 版本的移植流程。

移植

虚拟机

修改配置文件

root@ubuntu:/opt/Qt/qt-everywhere-opensource-src-5.6.3# vim 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

QT_QPA_DEFAULT_PLATFORM = linuxfb 
QMAKE_CFLAGS  += -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv7-a -mtune=cortex-a9
QMAKE_CXXFLAGS += -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv7-a -mtune=cortex-a9

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

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

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

建立安装目录

root@ubuntu:/opt/Qt/qt-everywhere-opensource-src-5.6.3# mkdir -p /usr/local/Qt5.6.3

建立一个 make_auto.sh 脚本

#!/bin/bash

#################################################
# Developer: SY
# Data     : 2017-9-16 10:26:13
# Function : Auto Configure Project
#################################################

./configure -prefix /usr/local/Qt5.6.3 \
  -opensource \
  -release \
  -confirm-license \
  -xplatform linux-arm-gnueabi-g++ \
  -shared \
  -qt-zlib \
  -no-gif \
  -qt-libjpeg \
  -no-opengl \
  -no-cups \
  -no-glib \
  -no-dbus \
  -no-rpath \
  -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 \
  -no-avx  \
  -no-openssl \
  -nomake tools \
  -qreal float \
  -qt-libpng \
  -tslib \
  -nomake examples \
  -I /usr/local/tslib/include \
  -L /usr/local/tslib/lib \
  • 支持多点触摸:-mtdev -xinput2 ,但是添加会出错。

执行脚本

root@ubuntu:/opt/Qt/qt-everywhere-opensource-src-5.6.3# ./make_auto.sh 
+ cd qtbase
+ /opt/Qt/qt-everywhere-opensource-src-5.6.3/qtbase/configure -top-level -prefix /usr/local/Qt5.6.3 -opensource -release -confirm-license -xplatform linux-arm-gnueabi-g++ -shared -qt-zlib -no-gif -qt-libjpeg -no-opengl -no-cups -no-glib -no-dbus -no-rpath -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-openssl -nomake tools -qreal float -qt-libpng -tslib -nomake examples -I /usr/local/tslib/include -L /usr/local/tslib/lib

This is the Qt Open Source Edition.

You are licensed to use this software under the terms of
the GNU Lesser General Public License (LGPL) version 2.1.
You are also licensed to use this software under the terms of
the GNU Lesser General Public License (LGPL) version 3.

You have already accepted the terms of the Open Source license.

Running configuration tests (phase 1)...
Done running configuration tests.
Creating qmake...
.Done.
Running configuration tests (phase 2)...
Warning: Disabling pkg-config since PKG_CONFIG_LIBDIR is not set and
the host's .pc files would be used (even if you set PKG_CONFIG_PATH).
Set this variable to the directory that contains target .pc files
for pkg-config to function correctly when cross-compiling or
use -pkg-config to override this test.
Warning: Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set.
Set this variable to your sysroot for pkg-config to function correctly when
cross-compiling or use -pkg-config to override this test.
checking for C++11...  yes.
checking for C++14...  no.
checking for default C++ standard edition...  yes.
checking for 64-bit std::atomic...  yes.
checking for ipc_sysv...  yes.
checking for mtdev...  no.
checking for dlopen...  no.
checking for libdl...  yes.
checking for DB2...  no.
checking for InterBase...  no.
checking for MySQL (thread-safe)...  no.
checking for MySQL (thread-unsafe)...  no.
checking for OCI...  no.
checking for ODBC...  no.
checking for iODBC...  no.
checking for PostgreSQL...  no.
checking for SQLite2...  no.
checking for TDS...  no.
checking for POSIX iconv...  yes.
checking for libproxy...  no.
checking for ICU...  no.
checking for PulseAudio...  no.
checking for FontConfig...  no.
checking for libudev...  no.
checking for evdev...  yes.
checking for tslib...  yes.
checking for xkbcommon...  no.
checking for XLib...  no.
checking for Xrender...  no.
checking for XInput2...  no.
checking for xcb...  no.
checking for GBM...  no.
checking for LinuxFB...  yes.
checking for KMS...  no.
checking for Mir client...  no.
checking for EGL...  no.
checking for FreeType...  no.
checking for STL...  yes.
checking for POSIX clock_gettime()...  yes.
checking for POSIX Monotonic Clock...  yes.
checking for posix_fallocate...  yes.
checking for mremap...  yes.
checking for getaddrinfo...  yes.
checking for inotify...  yes.
checking for eventfd...  yes.
checking for IPv6 interface name...  yes.
checking for getifaddrs...  yes.
checking for cloexec...  yes.
checking for PCRE...  no.
checking for OpenVG...  no.
checking for OpenVG...  no.
checking for OpenVG (lc includes)...  no.
checking for OpenVG (lc includes)...  no.
checking for alsa...  no.
checking for GStreamer 1.0...  no.
checking for GStreamer 0.10...  no.
Done running configuration tests.

   Configure summary

Building on:   linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for:  linux-arm-gnueabi-g++ (arm, CPU features: none detected)
Platform notes:

            - Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx

Build options:
  Configuration .......... accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile evdev eventfd freetype full-config getaddrinfo getifaddrs harfbuzz iconv inotify ipv6ifname large-config largefile linuxfb medium-config minimal-config mremap no-gif no-pkg-config pcre png posix_fallocate qpa qpa reduce_exports release shared small-config threadsafe-cloexec tslib zlib 
  Build parts ............ libs
  Mode ................... release
  Using sanitizer(s)...... none
  Using C++ standard ..... c++11
  Using gold linker....... no
  Using new DTAGS ........ no
  Using PCH .............. no
  Using LTCG ............. no
  Target compiler supports:
    Neon ................. no

Qt modules and options:
  Qt D-Bus ............... no
  Qt Concurrent .......... yes
  Qt GUI ................. yes
  Qt Widgets ............. yes
  Large File ............. yes
  QML debugging .......... yes
  Use system proxies ..... no

Support enabled for:
  Accessibility .......... yes
  ALSA ................... no
  CUPS ................... no
  Evdev .................. yes
  FontConfig ............. no
  FreeType ............... yes (bundled copy)
  Glib ................... no
  GStreamer .............. no
  GTK theme .............. no
  HarfBuzz ............... yes (bundled copy)
  Iconv .................. yes
  ICU .................... no
  Image formats: 
    GIF .................. no
    JPEG ................. yes (plugin, using bundled copy)
    PNG .................. yes (in QtGui, using bundled copy)
  libinput................ no
  Logging backends: 
    journald ............... no
    syslog   ............... no
  mtdev .................. no
  Networking: 
    getaddrinfo .......... yes
    getifaddrs ........... yes
    IPv6 ifname .......... yes
    libproxy.............. no
    OpenSSL .............. no
  OpenGL / OpenVG: 
    EGL .................. no
    OpenGL ............... no
    OpenVG ............... no
  PCRE ................... yes (bundled copy)
  pkg-config ............. no 
  PulseAudio ............. no
  QPA backends: 
    DirectFB ............. no
    EGLFS ................ no
      EGLFS i.MX6 ........ no
      EGLFS i.MX6 Wayland. no
      EGLFS EGLDevice .... no
      EGLFS GBM .......... no
      EGLFS Mali ......... no
      EGLFS Raspberry Pi . no
      EGLFS X11 .......... no
    LinuxFB .............. yes
    Mir client............ no
    XCB .................. no
  Session management ..... yes
  SQL drivers: 
    DB2 .................. no
    InterBase ............ no
    MySQL ................ no
    OCI .................. no
    ODBC ................. no
    PostgreSQL ........... no
    SQLite 2 ............. no
    SQLite ............... yes (plugin, using bundled copy)
    TDS .................. no
  tslib .................. yes
  udev ................... no
  xkbcommon-x11........... no
  xkbcommon-evdev......... no
  zlib ................... yes (bundled copy)

Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_bootstrap_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_concurrent.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_concurrent_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_core.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_core_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_gui.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_gui_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_network.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_network_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_platformsupport_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_printsupport.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_printsupport_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_sql.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_sql_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_testlib.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_testlib_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_widgets.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_widgets_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_xml.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_xml_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_lib_zlib_private.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qevdevkeyboardplugin.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qevdevmouseplugin.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qevdevtabletplugin.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qevdevtouchplugin.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qgenericbearer.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qico.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qjpeg.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qlinuxfb.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qminimal.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qoffscreen.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qsqlite.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qtslibplugin.pri: No such file or directory
Cannot read /opt/Qt5.7.0/qt-everywhere-opensource-src-5.6.3/qtbase/mkspecs/modules-inst/qt_plugin_qtuiotouchplugin.pri: No such file or directory

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/Qt5.6.3

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

然后执行:make -j4

然后执行:make install ,安装文件被安装到路径:/usr/local/Qt5.6.3

root@ubuntu:/opt/Qt/qt-everywhere-opensource-src-5.6.3# cd /usr/local/Qt5.6.3/
root@ubuntu:/usr/local/Qt5.6.3# ls
bin  doc  include  lib  mkspecs  plugins  qml  translations
root@ubuntu:/usr/local/Qt5.6.3# ls bin/
canbusutil        lrelease  qdoc   qml               qmlmin   qtplugininfo  uic
fixqt4headers.pl  lupdate   qlalr  qmlimportscanner  qtdiag   rcc           xmlpatterns
lconvert          moc       qmake  qmllint           qtpaths  syncqt.pl     xmlpatternsvalidator

其中:qmake 就是用于自动生成 Makefile 的工具,以后编译 qt 工程的时候会经常遇到。

开发板

将该目录下的所有文件拷贝到开发板的根文件系统:

root@ubuntu:/usr/local/Qt5.6.3# mkdir /opt/fs/rootfs/rootfs/usr/local/Qt5.6.3
root@ubuntu:/usr/local/Qt5.6.3# cp -a * /opt/fs/rootfs/rootfs/usr/local/Qt5.6.3/

修改配置文件

root@ubuntu:/opt/fs/rootfs/rootfs# cat etc/profile    
# /etc/profile: system-wide .profile file for the Bourne shells

echo ""
echo -n "Processing /etc/profile... "

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
HOSTNAME='/bin/hostname'

PS1='[\u@\h:\w]# '
PATH=$PATH

export USER LOGNAME PS1 PATH

# tslib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event0


export T_ROOT=/usr/local/tslib
export LD_LIBRARY_PATH=/usr/local/tslib/lib:$LD_LIBRARY_PATH
export TSLIB_PLUGINDIR=$T_ROOT/lib/ts
export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf
export POINTERCAL_FILE=/etc/pointercal
export TSLIB_CALIBFILE=/etc/pointercal

# Qt
export QTEDIR=/usr/local/Qt5.6.3
export LD_LIBRARY_PATH=/usr/local/Qt5.6.3/lib:$LD_LIBRARY_PATH
export QT_QPA_GENERIC_PLUGINS=tslib
export QT_QPA_FONTDIR=$QTEDIR/lib/fonts 
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/plugins 
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=800x480:mmSize=800x480:offset=0x0:tty=/dev/tty1
export QT_QPA_FB_TSLIB=1
export QT_QPA_FB_HIDECURSOR=/dev/input/mouse1
export LD_PRELOAD=$QTEDIR/lib/preloadable_libiconv.so


echo "Done!"

添加库

root@ubuntu:/opt/fs/rootfs/rootfs# cp /opt/Qt/libiconv-1.14/_install/lib/preloadable_libiconv.so usr/local/Qt5.6.3/lib/

添加字体

从友善之臂的光盘中拷贝字体:DroidSansFallback.ttf 放到开发板路径:/usr/local/Qt5.6.3/lib/fonts

添加字体路径:

[root@TINY4412:~]# vi etc/profile
export QTEDIR=/usr/local/Qt5.6.3
export QT_QPA_FONTDIR=$QTEDIR/lib/fonts

添加键盘

添加鼠标

添加触摸屏

添加虚拟键盘

测试

参考

移植QT5.6到嵌入式开发板(史上最详细的QT移植教程)

Qt-5.3.2 在友善Smart210开发板的移植记录

Qt:5.7虚拟键盘中拼音输入法的使用

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器