• armlinux 移植qt


    1、 编译 Tslib

    1.1 获取 tslib

    本文使用的是tslib-1.21.tar.bz2
    将tslib-1.21.tar.bz2解压

    sudo tar -jxvf tslib-1.21.tar.bz2
    
    • 1

    在这里插入图片描述

    1.2 配置 tslib

    先安装 automake 工具

    sudo apt-get install autoconf automake libtool
    
    • 1

    配置源码生成 Makefile

    ./autogen.sh
    
    • 1

    在这里插入图片描述

    1.3 配置交叉编译工具

    新建一个文件夹,用于存放编译输出的内容,在当前目录下新建,执行下面的指令

    mkdir arm-tslib
    
    • 1

    获取路径
    在这里插入图片描述
    指定交叉编译工具与输出路径指令为

    ./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/work/third-party/tslib-1.21/arm-tslib
    
    • 1

    在这里插入图片描述

    1.4 编译与安装

    执行make编译

    make -j2 //加参数-j2 是最多允许 2 条编译指令同时进行
    
    
    • 1
    • 2

    在这里插入图片描述
    编译完成
    在这里插入图片描述
    执行 make install 指令进行安装

    make install
    
    • 1

    在这里插入图片描述
    安装完成
    在这里插入图片描述

    2 编译Qt源码

    2.1 下载Qt源码

    路径http://download.qt.io/new_archive/qt/5.5/5.5.1/single/
    解压压缩包

    tar xf qt-everywhere-opensource-src-5.5.1.tar.xz 
    
    • 1

    在这里插入图片描述
    在这里插入图片描述

    2.2 配置编译选项

    进入该源码目录下, 首先我们先新建一个编译输出的文件夹,命名为 arm-qt。

    mkdir arm-qt
    
    • 1

    配置编译的选项

    gedit autoconfigure.sh
    
    • 1
    #!/bin/sh
    ./configure \
    	-prefix /home/work/third-party/qt-everywhere-opensource-src-5.5.1/arm-qt \
    	-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/home/work/third-party/tslib-1.21/arm-tslib/include \
    	-L/home/work/third-party/tslib-1.21/arm-tslib/lib
    exit
    
    • 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

    2.3 指定交叉编译工具及 tslib 的路径

    执行下面的指令,编辑 mkspecs/linux-arm-gnueabi-g++下的 qmake.conf。注意: mkspecs 下有很
    多平台选择,说明了 Qt 是跨平台的。之所以是选择 linux-arm-gnueabi-g++,这是因为前面
    autoconfigure.sh 里的参数-xplatform 选择了 linux-arm-gnueabi-g++。

    gedit qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
    
    • 1
    #
    # 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)
    
    #20220703 song
    QT_QPA_DEFAULT_PLATFORM = linuxfb
    QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
    QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
    
    
    # modifications to g++.conf
    QMAKE_CC                = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
    QMAKE_CXX               = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
    QMAKE_LINK              = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
    QMAKE_LINK_SHLIB        = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
    
    # modifications to linux.conf
    QMAKE_AR                = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar cqs
    QMAKE_OBJCOPY           = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objcopy
    QMAKE_NM                = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm -P
    QMAKE_STRIP             = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip
    
    QMAKE_INCDIR += /home/work/third-party/tslib/arm-tslib/include
    QMAKE_LIBDIR += /home/work/third-party/tslib/arm-tslib/lib
    load(qt_config)
    
    • 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

    2.4 执行 autoconfigure.sh 配置

    先添加可执行权限

    chmod +x autoconfigure.sh
    
    • 1

    执行配置
    在这里插入图片描述
    qmake 创建完成后,看到下图的“Just run make” ,说明是可以开始编译了,如果你还没有看见
    这句话,请再检查路径是否配置正确,编译器路径等是否正确
    在这里插入图片描述

    2.5 执行 make 编译

    在 Qt 源码下执行 make 编译。
    在这里插入图片描述

    2.6 执行 make install 安装

    执行 make install 安装到指定文件夹
    在这里插入图片描述
    查看安装结果
    在这里插入图片描述
    查看 qmkae 的版本
    在这里插入图片描述

    2.7 移植到开发板

    2.7.1 移植 tslib 到开发板

    将编译好的 arm-tslib 拷贝到不含qt 的文件系统中。

    在这里插入图片描述
    打开/etc/profile 文件,添加环境变量

    export T_ROOT=/opt/tslib
    export PATH=$PATH:$T_ROOT/bin 
    export LD_LIBRARY_PATH=$T_ROOT/lib:$LD_LIBRARY_PATH
    export TSLIB_CONSOLEDEVICE=none
    export TSLIB_FBDEVICE=/dev/fb0
    export TSLIB_TSDEVICE=/dev/input/event1
    export TSLIB_CALIBFILE=/etc/pointercal
    export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf
    export TSLIB_PLUGINDIR=$T_ROOT/lib/ts/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    在这里插入图片描述
    拷贝完成后,保存退出。 使用 source 指令导出刚刚设置的环境变量。

    source /etc/profile
    
    • 1

    测试 tslib 是否可用, tslib 的工具所在的文件夹在 tslib/bin 下,我们可以利用这些工具来测试我们的触摸屏是否能触摸。
    先切换到root
    在这里插入图片描述

    2.7.2 移植 Qt 到开发板

    编译好的 arm-qt 拷贝到不含 qt的文件系统中
    在这里插入图片描述
    同 tslib 一样,我们要设置 Qt 的环境变量,好让系统知道 Qt 库的位置在哪里!要想 Qt 程序显示中文,请自行将 windows 下的中文字库放到/opt/arm-qt/lib/fonts 这个目录下就可以了。
    添加环境变量

    vi /etc/profile
    
    • 1
    export QT_ROOT=/opt/arm-qt
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event1:edevmouse:/dev/input/event3
    export QT_QPA_FONTDIR=/opt/arm-qt/lib/fonts
    export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
    export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
    export QT_PLUGIN_PATH=$QT_ROOT/plugins
    export LD_LIBRARY_PATH=$QT_ROOT/lib:$QT_ROOT/plugins/platforms
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述
    拷贝完成后,保存退出。使用 source 指令导出刚刚设置的环境变量。

    source /etc/profile
    
    • 1

    可使用 env 指令查看,设置的环境变量
    在这里插入图片描述

  • 相关阅读:
    Java面试题总结(三)
    java(面向对象)的23种设计模式(10)——模板方法模式
    数据库查询详解
    维修一款20年前的电容测试表VC6013
    进程的通信 - 邮槽
    Eslint安装配置教程
    springboot吕梁学院导师制管理系统毕业设计源码251022
    linux 修改静态ip立即生效,无需重启
    (c语言进阶)内存函数
    133道Java面试题及答案(面试必看)
  • 原文地址:https://blog.csdn.net/L1643319918/article/details/125582081