qtopia移植
注: 此贴转自我们以前的Google协作平台!
因为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 我的解决办法: 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 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根目录下,然后在板子上设置环境变量,各个环境变量的含义如下: 我板子上的环境变量如下: 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的环境变量,最终确定的环境变量如下: 遇到的错误: 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 无法加载。所以才提示找不到文件或目录!
从以上分析来看,问题出在环境变量的设置上,有两种可能:
|