记录一下移植Qt到arm开发板过程

一、tslib移植(不用屏幕时不需要移植)

     tslib介绍:

            tslib是嵌入式开发中使用qt开发之前需要搭建的一个必须的环境,通过tslib,你编写的qt程序才能通过触摸屏进行操作,而tslib进行进行你的qt程序和硬件之间的接口

    下载:

https:///libts/tslib/releases

    工具:

sudo apt-get install autoconf automake libtool

    交叉编译:

./configure --host=-host=arm-linux-gnueabihf  --cache-file=arm-linux.cache --prefix=/home/vmuser/tslib/arm-linux/
make
make install

    目前调试板子上没有屏幕,因此暂时不需要移植这个库

二、Qt交叉编译

    源码下载:

https://download.qt.io/new_archive/qt/5.6/5.6.3/single/qt-everywhere-opensource-src-5.6.3.zip

    qmake修改(修改对应工具链,注意工具链要使用较新的版本,老版本可能会报错):

vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf

    文件格式修改:

#下载下来的源码为windows下编辑的,文件格式不一样,因此在linux中执行的时候会有格式错误,需要重新设置文件格式
#否则会报错误 sh: ./configure: /bin/bash^M: bad interpreter: No such file or directory
vim configure
vim qtbase/configure
#which.test不修改会报 You don't seem to have 'make' or 'gmake' in your PATH.
#which.test会制定make和gmake路径,如果此文件格式异常则导致只在当前目录而不是/usr/bin下搜索
vi qtbase/config.tests/unix/which.test
vi qtbase/config.tests/unix/precomp.test
vi qtbase/config.tests/unix/fvisibility.test
vi qtbase/config.tests/unix/arch.test
vi qtbase/config.tests/unix/bsymbolic_functions.test
vi qtbase/config.tests/unix/compile.test
vi qtbase/config.tests/x11/notype.test
vim configure

:set ff=unix

:wq

    编译(先不使用tslib,注意打印出Attempting to skip non-existent这个时候说明skip跳过的模块不存在会直接退出不生成Makefile):

#!/bin/bash
./configure \
    -prefix /home/vmuser/Qt5.6/qt-src/qt-arm/ \
    -opensource \
    -confirm-license \
    -release \
    -strip \
    -shared \
    -xplatform linux-arm-gnueabi-g++ \
    -optimized-qmake \
    -c++std c++11 \
    --rpath=no \
    -pch \
    -skip qt3d \
    -skip qtactiveqt \
    -skip qtandroidextras \
    -skip qtcanvas3d \
    -skip qtconnectivity \
    -skip qtdoc \
    -skip qtlocation \
    -skip qtmacextras \
    -skip qtscript \
    -skip qtsensors \
    -skip qtsvg \
    -skip qttools \
    -skip qttranslations \
    -skip qtwayland \
    -skip qtwebengine \
    -skip qtwebview \
    -skip qtwinextras \
    -skip qtx11extras \
    -skip qtxmlpatterns \
    -make libs \
    -make examples \
    -nomake tools -nomake tests \
    -gui \
    -widgets \
    -dbus-runtime \
    --glib=no \
    --iconv=no \
    --pcre=qt \
    --zlib=qt \
    -no-openssl \
    --freetype=qt \
    --harfbuzz=qt \
    -no-opengl \
    -linuxfb \
    --xcb=no \
    -no-tslib \
    --libpng=qt \
    --libjpeg=qt \
    -no-iconv \
    -plugin-sql-sqlite

三、Qt主题美化:

    ubuntu环境下默认的主题挺难看的,可以从github上下载一些主题,自己更新配置,但是这个只有文本风格,主题风格好像没人写。。。。。

开发工具solarized主题配置

    修改路径(如果没有styles和themes目录那就自己创建一个):

#修改路径 /usr/share/qtcreator
#推荐路径 ~/.config/QtProject/qtcreator/
#修改代码界面
~/.config/QtProject/qtcreator/styles
#修改界面风格
~/.config/QtProject/qtcreator/themes/

  自己比较喜欢solarized的暗色系列风格,github上找了下有文本格式的solorized-dark.xml,但是solarized主题颜色没有。

    自己尝试写了个,但是暗色主题卡死在一个背景颜色(TextColorNormal),会根据字体颜色自动修改背景,麻了。

arm 服务器 python_arm

        整体效果如下,可能有个别效果没有兼顾到

(链接  solarized-dark.creatortheme):

(链接 solarized-light.creatortheme)

arm 服务器 python_arm_02

       四、配置(设置工具链以及qmake,项目生成路径自己配置):

工具链版本过低会报错

arm 服务器 python_qt_03

arm 服务器 python_arm_04

arm 服务器 python_Qt_05

        测试:

新建一个项目,然后打印helloworld,发现构建后生成的目录不对劲

arm 服务器 python_arm_06

在项目中,先取消勾选shadow build,然后再重新勾选,设置生成的目录名到build下

arm 服务器 python_arm 服务器 python_07

        运行:

        将构建出的文件拷贝到板子上(项目类型为Qt Console Application),运行是会提示缺失相应的库,根据提示将对应的库拷贝到板子的lib目录下

        如果需要调试屏幕的话,项目新建时类型为Qt Widgets Application,并且需要设置/etc/profile/,拷贝plugins目录到板子上等等,这个后续再研究