本编介绍如何在嵌入式linux开发板上配置qt运行环境,并进行qt程序运行测试。
1 tslib编译 tslib之前在测试触摸屏的时候使用过,这里再来记录一下编译过程。
下载tslib库的源码:https://github.com/libts/tslib/tags
将下载的源码拷贝到ubuntu虚拟机中,然后解压:
tar xvf tslib-1.21.tar.bz2 编译 tslib 的时候需要先在 ubuntu 中安装一些文件:
sudo apt-get install autoconf sudo apt-get install automake sudo apt-get install libtool 在 ubunt中创建一个名为“tslib”的目录存放编译结果,然后执行以下指令进行编译:
./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/xxpcb/mytest/imx6ull/otherlib/tslib-2/tslibmakemake install 编译完成后,make install会将编译成果复制到指定的tslib目录中:
将tslib文件夹先整个打包为arm-tslib.tar.bz2文件,后面移植到开发板时用:
tar -jcf arm-tslib.tar.bz2 tslib
2 qt源码编译 2.1 下载qt5的源码 下载地址:https://download.qt.io/archive/qt/5.15/5.15.2/single/
将下载的qt-everywhere-src-5.15.2.tar.xz拷贝到ubuntu中,然后解压:
tar -xvf qt-everywhere-src-5.15.2.tar.xz 2.2 修改qmake.conf 修改qtbase/mkspecs/linux-arm-gnueabi-g++/中的qmake.conf文件
这个文件默认的内容是:
## qmake configuration for building with arm-linux-gnueabi-g++#makefile_generator = unixconfig += incrementalqmake_incremental_style = sublibinclude(../common/linux.conf)include(../common/gcc-base-unix.conf)include(../common/g++-unix.conf)# modifications to g++.confqmake_cc = arm-linux-gnueabi-gccqmake_cxx = arm-linux-gnueabi-g++qmake_link = arm-linux-gnueabi-g++qmake_link_shlib = arm-linux-gnueabi-g++# modifications to linux.confqmake_ar = arm-linux-gnueabi-ar cqsqmake_objcopy = arm-linux-gnueabi-objcopyqmake_nm = arm-linux-gnueabi-nm -pqmake_strip = arm-linux-gnueabi-stripload(qt_config) 修改成如下:
2.3 配置编译选项 查看编译选项,输入./configure -help 指令,查看可配置选项
./configure -help 可以看到配置项有很多,因此可以使用一个配置脚本来进行配置。
编写一个autoconfigure.sh文件,然后根据自己的情况,写入如下配置:
./configure -prefix /home/xxpcb/mytest/imx6ull/otherlib/qt/qt-everywhere-src-5.12.9/arm-qt \-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 qtdatavis3d \-skip qtdoc \-skip qtgamepad \-skip qtlocation \-skip qtmacextras \-skip qtnetworkauth \-skip qtpurchasing \-skip qtremoteobjects \-skip qtscript \-skip qtscxml \-skip qtsensors \-skip qtspeech \-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 \-tslib \--libpng=qt \--libjpeg=qt \--sqlite=qt \-plugin-sql-sqlite \-i/home/xxpcb/mytest/imx6ull/otherlib/tslib-2/tslib/include \-l/home/xxpcb/mytest/imx6ull/otherlib/tslib-2/tslib/lib \-recheck-all 注意其中3处是自己的配置路:
1 /home/xxpcb/mytest/imx6ull/otherlib/qt/qt-everywhere-src-5.12.9/arm-qt 为编译输出路径。
2 /home/xxpcb/mytest/imx6ull/otherlib/tslib-2/tslib/include 为tslib 头文件路径。
3 /home/xxpcb/mytest/imx6ull/otherlib/tslib-2/tslib/lib 为tslib相关库文件路径。
其它一些参数的含义:
-opensource:构建qt的开源版本
-release:使用release版本的qt
-xplatform linux-arm-gnueabi-g++:指定编译器
-skip qt3d:跳过qt的3d
-make libs:编译要用到的库
-make examples:编译生成qt的例程代码
-nomake tools:不生成qt的工具
-no-openssl:不使用openssl
2.4 编译 配置前需要先安装 g++
sudo apt-get install g++ 赋予脚本可执行权限,然后执行 autoconfigure.sh
chmod +x autoconfigure.sh./autoconfigure.sh 运行完成之后:
然后就可以执行make指令进行编译了。
编译大约需要十几到几十分钟。
编译完成之后,再执行make install进行安装,安装之后就可以看到arm-qt文件中的内容了:
将qrm-qt文件夹先整个打包为arm-qt.tar.bz2文件,后面移植到开发板时用:
tar -jcf arm-qt.tar.bz2 arm-qt 2.5 编译出错的问题 make编译时可能会遇到编译出错
情况1:我遇到过下面这种:
这种情况是因为我的ubuntu虚拟机空间不够用了,解决方法就是给虚拟器扩容,具体操作过程见:
情况2:编译最新版本的qt源码报错
使用qt最新版本5.15.2编译报错,暂未找到解决方法,所以我先用5.12.9版本的qt。
3 开发板上配置qt环境 3.1 复制tslib和qt的编译文件 将之前打包的arm-tslib.tar.bz2和arm-qt.tar.bz2压缩包复制到板子中,可以先复制到nfs网络位置,然后解压到/usr/lib 目录下,解压后开删除无用的压缩包。
这是对arm-qt的操作步骤:
cp arm-qt.tar.bz2 ~/mytest/nfs/rootfs/usr/libcd ~/mytest/nfs/rootfs/usr/lib/tar xf arm-qt.tar.bz2rm arm-qt.tar.bz2 arm-tslib复制与解压过程类似。
3.2 设置开发板的环境变量 编辑/etc/profile,写入如下内容:
export tslib_root=/usr/lib/arm-tslib export tslib_consoledevice=none export tslib_fbdevice=/dev/fb0 export tslib_tsdevice=/dev/input/event1 export tslib_conffile=$tslib_root/etc/ts.conf export tslib_plugindir=$tslib_root/lib/ts export tslib_calibfile=/etc/pointercal export ld_preload=$tslib_root/lib/libts.soexport qt_root=/usr/lib/arm-qt export qt_qpa_generic_plugins=tslib:/dev/input/event1 export qt_qpa_fontdir=/usr/share/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 export qml2_import_path=$qt_root/qml export qt_qpa_fb_tslib=1 然后使该配置立即生效:
source /etc/profile 4 qt运行测试 qt的编译文件中,自带的qt的一些例子,可以先来在板子上运行这些例子看看qt程序能否在板子上正常运行。
这是运行其中的一个程序:
/usr/lib/arm-qt/examples/widgets/animation/animatedtiles/animatedtiles
友尚推出了的电机空气压缩机解决方案
区块链为何在比特币猛涨的情况下一脸冷漠
接触器不吸合如何处理
如何为系统仿真对数据转换器进行建模?
面板厂产能恐过剩 10月起价跌显现供过于求
嵌入式Linux-Qt环境搭建 Qt程序运行测试
QMC独家技术开发出的高效率Micro LED巨量转移设备
台达UPS再创佳绩 成功入驻吉林联通
高压隔离探头的维护和应用是怎样的
基于FPGA和SC1462的高速预检仪表应用,可替代ADS8509
湖北大学研制超稳定纳米卷轴,用于食品安全光电传感
镭神智能3D SLAM解决方案助力叉车行业转型升级!
南开大学孙军教授:逆流而上,为光电材料尽一份力
全球无晶圆/IC市场将保持增速,促进半导体产业的发展
什么是信标链区块
NI发布业界最高精度的PXI源测量单元
苏州视立得Type-C接头有无外壳的机器视觉检测技术
USB转UART桥接芯片DPU02介绍
直流无刷电机的工作原理及Matlab/Simulink仿真分析
雪铁龙新款微型电动汽车,充电只要三个小时