编译 ARM 版本 QT 库

往 Mini2440 开发板中移植 QT 应用程序时,需要用 QTCreater 交叉编译代码。而应用程序依赖于一系列的库,这就需要编译 ARM 版本的 QT 库。

编译 ARM 版本 QT 库

1.安装交叉编译环境 arm-linux-gcc 并设置好环境变量。

2.编译安装与触屏校对显示相关的库 tslib1.4.tar.gz,具体步骤参考 Mini2440移植qt-extended4.4.3。需要注意的是编译时需要设置编译链采用 arm-linux-g++。通过下列命令来进行指定。

./configure--host=arm-linux --cache-file=arm-linux.cache \
PLUGIN_DIR=/usr/local/arm/tslib/plugins  \
-prefix=/usr/local/arm/tslib/build -host=arm-linux --cache-file=arm-linux.cache2>&1 | tee conf_log

3.交叉编译安装 qt 库 qt-everywhere-opensource-src-4.6.4.tar.gz,具体步骤参考 Qtcreator配置、交叉编译arm程序。同时也需要设置编译链采用 arm-linux-g++。通过下列命令来进行指定。

./configure -opensource -embedded arm -xplatform qws/linux-arm-g++  
-no-webkit -qt-libtiff -qt-libmng  -qt-mouse-tslib -qt-mouse-pc 
-no-mouse-linuxtp -prefix /opt/Qt4.6.4_forArm 
-I /usr/local/arm/tslib/tslib/include -L /usr/local/arm/tslib/tslib/lib

设置 QTCreater 来交叉编译应用程序

主要是三步:设置 QT 版本(Qt-embeded-arm 库位置)——设置编译器(arm-linux-g++)——设置构建套件

具体步骤参考 Qtcreator配置、交叉编译arm程序

传送文件到 ARM

1.建立 FTP 连接。ftp 202.201..

2.切换到需要传送文件所在目录 lcd /home/huang/Desktop/Quantizer4ARM/build-Quantizer-ARM-Debug

3.传送文件 put Quantizer

4.运行 QT 程序 ./Quantizer -qws

触摸屏失效解决

主要想法是使用 FriendlyARM 的启动脚本。修改 /bin/qt4 脚本为下列 AppLauncher.sh,用它来启动应用程序。

#!/bin/sh
export TSLIB_TSDEVICE=/dev/input/event0 
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export LD_LIBRARY_PATH=/
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin:/usr/local/bin
export QWS_DISPLAY=:1
TS_INFO_FILE=/sys/devices/virtual/input/input0/uevent
if [ -e $TS_INFO_FILE -a "/bin/grep -q TouchScreen < $TS_INFO_FILE" ]; then
export QWS_MOUSE_PROTO="Tslib:/dev/input/event0 MouseMan:/dev/input/mice"
if [ ! -s /etc/pointercal ] ; then
rm /etc/pointercal
/usr/local/bin/ts_calibrate
fi
else
export QWS_MOUSE_PROTO="MouseMan:/dev/input/mice"
fi
unset TS_INFO_FILE
export QWS_KEYBOARD=TTY:/dev/tty1
export HOME=/root
cd /usr/local/Trolltech/QtEmbedded-4.6.3-arm/demos/embedded/fluidlauncher
$1 -qws
hotplug

使用 ./AppLauncher.sh ./Quantizer 打开 QT 应用程序。具体步骤参考 Qt在mini2440下的触摸屏失效和库文件找不到问题的解决

QT 版本问题

在开发板上运行程序出现错误

./Quantizer: symbol lookup error: ./Quantizer: undefined symbol: _ZNK6QImage13constScanLineEi

程序读图片使用

const uchar *pSrc = (uchar *)image.constScanLine(i)

这是 Qt 4.8 版本中的,PC 上编译的 QT-embedded-qt 库是 4.8.6 版本的,而 ARM 开发板中的动态链接库是 4.6.3 版本。

将代码改为

uchar *pSrc = (uchar *)image.scanLine(i)

即可正常工作。

参考

mini2440运行Qt程序技巧

Qt程序运行在mini2440开发板上

Qtcreator配置、交叉编译arm程序

转载于:https://my.oschina.net/lvyi/blog/645319

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值