qtopia移植

12 篇文章 0 订阅
2 篇文章 0 订阅

qtopia移植

注: 此贴转自我们以前的Google协作平台!

qtopia: qtopia-core-opensource-src-4.3.3
tslib : tslib-1.3


因为qt对触屏的支持是通过tslib来实现的,Tslib能够为触摸屏驱动获得的采样提供诸如滤波、去抖、校准等功能,通常作为触摸屏驱动的适配层,为上层的应用提供了一个统一的接口(如果想要了解tslib的校准原理可以参见这里 )。但是qtopia-core-opensource-src-4.3.3本身不带有tslib的库,它是以插件的形式来实现调用的,这就给我们带来了很大的不便。不是我们惯用的那一招`configure-make-make install`所能解决的问题了。但这也不是说他就不可能移上去,相信你自己,`世界上没有你做不成的事,这只是时间问题。` 。首先分析问题:
既然QT需要调用tslib的库,那我们就首先要编译tslib喽,然后在编译QT的时候加上tslib的头文件和lib库,ok,这是大体思路,下面开始操作。

1. 编译tslib-1.3

下载-解压-进入tslib目录 ,然后执行autogen.sh脚本用来生成configure脚本。

debian:/work/pro/tslib-1.0# ./autogen.sh

configure.ac:7: installing `./install-sh'
configure.ac:7: installing `./missing'
plugins/Makefile.am: installing `./depcomp'

debian:/work/pro/tslib-1.0# ./configure CC=arm-linux-gcc CXX=arm-linux-g++ -prefix=$(YOUR_TARGET_DIR) -host=arm-linux

在这里估计你也出现了下面的错误提示:

arm-linux-gcc -O2 -Wall -W -o .libs/ts_test ts_test.o fbutils.o font_8x8.o font_8x16.o ../src/.libs/libts.so -ldl
ts_test.o(.text+0x218): In function `main':
: undefined reference to `rpl_malloc'
fbutils.o(.text+0x234): In function `open_framebuffer':
: undefined reference to `rpl_malloc'
collect2: ld returned 1 exit status
make[2]: *** [ts_test] Error 1
make[2]: Leaving directory `/work/pro/tslib-1.0/tests'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/work/pro/tslib-1.0'
make: *** [all] Error 2

关于这个错误,我参考了 李先静 老师的博客之《交叉编译场景分析(arm-linux)(二)--编译tslib 》,他对这个问题讲解很透彻,下面引用原话>>>>:
在 当前目录查找了rpl_malloc,发现configure里有#define malloc rpl_malloc一行。分析configure 脚本相关的代码,原来是ac_cv_func_malloc_0_nonnull引起的,OK我们不让它检查了,产生一个cache文件arm- linux.cache,欺骗configure:

[root@linux tslib]# echo "ac_cv_func_malloc_0_nonnull=yes" >$ ARCH -linux.cache

[root@linux tslib]# ./configure --prefix=$(ROOTFS_DIR)/usr --host=$ ARCH -linux --cache-file=$ ARCH -linux.cache
<<<<引用完毕


我的解决办法:
debian:/work/pro/tslib-1.0# echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache

debian:/work/pro/tslib-1.0# ./configure CC=arm-linux-gcc CXX=arm-linux-g++ PLUGIN_DIR=/usr/local/tslib/plugins -prefix=/usr/local/tslib -host=arm-linux --cache-file=arm-linux.cache 2>&1 | tee conf_log

你可能不理解最后的参数`2>&1 | tee conf_log `, 它是用来把configure的输出结果放到conf_log里面,便于我们查看。


debian:/work/pro/tslib-1.0# make 2>&1 | tee make_log
debian:/work/pro/tslib-1.0# make install

ok,下一步做测试,首先把安装目录下的bin文件夹和lib文件夹copy到nfs根目录下,然后在板子上设置环境变量,各个环境变量的含义如下:

TSLIB_TSDEVICE    触摸屏设备文件名。
                Default (non inputapi): /dev/touchscreen/ucb1x00
                Default (inputapi): /dev/input/event0
TSLIB_CALIBFILE    校准的数据文件,可以用ts_calibrate生成。
                Default: ${sysconfdir}/pointercal
TSLIB_CONFFILE     主配置文件名。
                Default: ${sysconfdir}/ts.conf
TSLIB_PLUGINDIR  插件目录
                Default: ${datadir}/plugins
TSLIB_CONSOLEDEVICE  控制台设备文件名
                Default: /dev/tty
TSLIB_FBDEVICE Framebuffer  设备名
                Default: /dev/fb0


我板子上的环境变量如下:
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_PLUGINDIR=/mnt/nfs/tslib/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CONFFILE=/mnt/nfs/tslib/etc/ts.conf
export TSLIB_CALIBFILE=/mnt/yaffs/pointercal            
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs/tslib/lib

运行bin文件夹下的例子,这里略去。


2. 编译qtopia-core-opensourse-4.3.3

现在可以编译qtopia了,configure的参数参考help来自己确定,下面的是我选择的参数:

debian:/work/pro/qtopia# ./configure -prefix /mnt/nfs/QtopiaCore -embedded arm -xplatform qws/linux-arm-g++ -depths 8,16,32 -no-qt3support -no-largefile -no-mouse-linuxtp -no-mouse-pc -no-mouse-pc -no-mouse-bus -no-mouse-yopy -no-mouse-vr41xx -no-mouse-qvfb -qt-mouse-tslib -I /usr/local/tslib/include (触摸屏的头文件) -L /usr/local/tslib/lib (触摸屏的库文件) 2>&1 | tee conf_log

This is the Qtopia Core Open Source Edition.

You are licensed to use this software under the terms of
the GNU General Public License (GPL).

Type 'G' to view the GNU General Public License.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.

Do you accept the terms of the license? yes

----------------------------此处但且省略N行-----------------------------

下面的是configure产生的信息:

Debug ............... no
Qt 3 compatibility .. no
QtDBus module ....... no
STL support ......... yes
PCH support ......... no
MMX/3DNOW/SSE/SSE2.. no/no/no/no
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... no
CUPS support ........ no
Iconv support ....... no
Glib support ........ no
Large File support .. no
GIF support ......... plugin
TIFF support ........ plugin (qt)
JPEG support ........ plugin (qt)
PNG support ......... yes (qt)
MNG support ......... plugin (qt)
zlib support ........ yes
Embedded support .... arm
Freetype2 support ... auto (yes)
Graphics (qt) ....... linuxfb multiscreen
Graphics (plugin) ...
Decorations (qt) .... styled windows default
Decorations (plugin)
Keyboard driver ..... tty
Mouse driver (qt) ... tslib
Mouse driver (plugin)
OpenGL support ...... no
SQLite support ...... plugin (qt)
OpenSSL support ..... no

----------------------------此处但且省略N行-----------------------------

开始make-make install:

debian:/work/pro/qtopia# make 2>&1 |tee make_log
debian:/work/pro/qtopia# make install

把生成的lib文件夹copy到nfs根目录的Qtopia文件夹下,然后在安装目录的bin文件夹下找几个小例子copy到nfs根目录下做测试。测试前要先设置一下环境变量,环境变量的确定可以参考Qtopia Core Environment Variables 。 加上tslib的环境变量,最终确定的环境变量如下:

#!/bin/sh
export QTDIR=/mnt/nfs/QtopiaCore
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_PLUGINDIR=/mnt/nfs/tslib/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CONFFILE=/mnt/nfs/tslib/etc/ts.conf
export TSLIB_CALIBFILE=/mnt/yaffs/pointercal
export POINTERCAL_FILE=/mnt/yaffs/pointercal
export QWS_MOUSE_PROTO=Tslib:/dev/input/event0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/nfs/tslib/lib:$QTDIR/lib


遇到的错误:

Couldnt load module pthres

No raw modules loaded

tsconfig: Success


tslib 通过 cstdlib 库里的一个函数 getenv 来得到指定系统环境变量的值,其环境变量默认的值在 readme 中有注明。

加载插件模块时 ts_calibrate 会打开 ts_config

ts_config 函数里首先会读取 tslib 配置文件( ts.conf ,由 TSLIB_CONFFILE 环境变量指定 ,tslib/etc 下面), 然后根据这个文件逐个加载插件库。

我的ts.conf 内容为

module_raw input

module pthres

module variance delta=30

module dejitter delta=100

module linear

ts_config 又会调用 ts_load_module 加载库。从这个函数里,程序先是得到配置文件中指定加载的模块名,然后根据模块名构造了一个 so 文件文件名,然后调用了系统函数 dlopen 加载库!

Linux 下的加载 dlopen 类似于 Windows 下动态链接库的函数: dlopen

错误就应该出在构造的库文件名是错误的 --- 其指定的文件不存在

--- 从而导致 dlopen 无法加载。所以才提示找不到文件或目录!

从以上分析来看,问题出在环境变量的设置上,有两种可能:
  1. TSLIB_CONFFILE没有设置
  2. TSLIB_PLUGINDIR没有设置

总结: 移植过程是繁琐的,但结果是令人欣慰的。网上的这类文章很多,但毕竟不是自己的,看上去都那么陌生,只有自己动手做了,才能体会到真正的快乐。突然想起来NIKE的那句广告词:Just do it! 呵呵,的确如此!
还是那句话: `世界上没有你做不成的事,这只是个时间问题。`

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值