引用自:http://blog.163.com/zhuandi_h/blog/static/180270288201222310291262/
http://blog.csdn.net/water_cow/article/details/7215308
注:大部分内容是转载他人,有一些是根据我编译的ubuntu系统出现的记录,只是为了方便大家学习。
环境:
host:Ubuntu11.10
target:Omap35X EVm
交叉编译链:4.3.2,Sourcery G++ Lite 2008q1-126 for ARM GNU/Linux
tslib源代码:tslib-1.4.tar.gz
tslib安装目标路径:/usr/local/arm-linux/tslib1.4
安装步骤:
1.准备工作
确保以下软件已安装
# apt-get install autoconf(或autoconf2.13) # apt-get install automake # apt-get install libtool
2.下载
http://download.csdn.net/detail/scholar_fish/4167788
下载版本为tslib-1.4.tar.gz
3.配置
解压源代码tslib-1.4.tar.gz,并进入源代码文件夹
配置# tar -zxvf tslib-1.4.tar.gz # cd tslib
注意,prefix选项更换为你的安装路径。# ./autogen.sh # echo "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache
# ./configure --host=arm-linux CC=arm-none-linux-gnueabi-gcc --cache-file=arm-none-linux-gnueabi.cache --enable-inputapi=no --enable-static=yes --enable-shared=no --prefix=/home/arm/tslib_arm/tslib1.4
--enable-static=yes 表示编译静态链接库
--enable-shared=no 表示禁止编译动态链接库
4.编译
# make
5.安装
编译生成的库,头文件等都拷贝至prefix制定的路径中。# make install
6. 修改ts.conf内容
打开 安装路径 下的/etc/ts.conf文件,修改其内容。
# vi /home/arm/tslib_arm/tslib1.4/etc/ts.conf
搜索定位至#module_raw input,把行首的注释符去掉, 但要注意行首不要留有空格,即文字是顶格的, 不然之后会出现段错误(segmentational fault)。
7.移植至开发板
将安装路径下的整个tslib文件夹,下载至开发班的上,我存放的路径为/usr/local
8. 设置开发板环境变量
通过超级终端, 打开环境变量文件/etc/profile
添加如下内容:# vi /etc/profile
其中,TSLIB_ROOT更换为自己实际存放的路径;export TSLIB_ROOT=/usr/local/tslib export TSLIB_TSDEVICE=/dev/input/event1
export QWS_MOUSE_PROTO=tslib:/dev/input/event1 export TSLIB_CALIBFILE=/etc/pointercal export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_CONSOLEDEVICE=none export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
另外,TSLIB_TSDEVICE 和QWS_MOUSE_PROTO这两项需要查看自己的板子的触摸屏设备对应/dev/input/下那个文件
9.执行测试命令
重启开发板(使系统读取profile环境变量),进入tslib/bin目录,执行触摸屏校准程序
如果出现tslib的触摸屏 五点 校准画面,至此,tslib的安装移植成功完成。# ./ts_calibrate
也可执行此目录下其他的程序来体验触摸屏!
10.出错记录
(1)编译可能遇到的问题与解决方法(ubuntu系统)
下面是我在移植Tslib工具过程中所遇到的一些问题与解决方法:
问题1.执行./configure提示
checking whether make sets $(MAKE)... (cached) yes
./configure: line 4802: syntax error near unexpected token `build_old_libs,'
./configure: line 4802: ` _LT_DECL(build_old_libs, enable_static, 0,'
解决方法:
打开configure文件,把所有_LT_DECL语句注释掉,编译通过。
问题2.执行./autogen.sh提示
./autogen.sh: 4: autoreconf:not found
解决方法:
没有安装automake 工具,
(ubuntu 10.04)用下面的命令安装:
sudo apt-get install autoconf automake libtool
问题3.执行./autogen.sh后出现错误信息:
libtoolize: `configure.in' does not exist
Try `libtoolize --help' for more information.
autoreconf: libtoolize failed with exit status: 1
解决方法:
#whereis libtoolize
libtoolize: /usr/bin/libtoolize /usr/local/bin/libtoolize
发现出现该错误信息是由于系统中安装了两个ilbtoolize工具链。将/usr/local/bin/libtoolize删除后问题解决(将/usr/bin/libtoolize删除后问题依然存在)。
问题4.执行./autogen.sh出现错误信息:
/autogen.sh: 4: autoreconf: not found
解决方法:
安装autoconf工具包。
问题5.执行make后出现错误信息:“…/usr/local ”is a directory …..
解决方法:该问题出现原因是由于配置好环境变量后,但系统编译时仍无法找到工具链导致。打开新的窗口,重新配置环境变量后编译此问题解决。
问题6.执行make后出现错误信息:
ts_test.o: In function `main':
ts_test.c:(.text+0x3b4): undefined reference to `rpl_malloc'
fbutils.o: In function `open_framebuffer':
fbutils.c:(.text+0x2f8): undefined reference to `rpl_malloc'
collect2: ld returned 1 exit status
解决方法:
执行# ./configure --host=mipsel-linux --prefix=/TSLIB后,在config.h中将“#define malloc rpl_malloc malloc”注释掉,编译通过。
问题7.执行make后出现错误信息:
In function ‘open’,
inlined from ‘main’ at ts_calibrate.c:227:
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
In function ‘open’,
inlined from ‘main’ at ts_calibrate.c:229:
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
解决方法:
sudo vim /home/loongson/workspace/tslib/tests/ts_calibrate.c +227将cal_fd = open (calfile, O_CREAT | O_RDWR);改为
cal_fd = open (calfile, O_CREAT | O_RDWR,0666);
229行
将cal_fd = open ("/etc/pointercal", O_CREAT | O_RDWR);
改为cal_fd = open ("/etc/pointercal", O_CREAT | O_RDWR,0666);
(2)第4步make时出现以下错误:
原因:直接copy了网络上的以下配置参数,参数中的”malloc_0 _nonnull"中多了一个空格。ts_test.o: In function `main': ts_test.c:(.text+0x1d4): undefined reference to `rpl_malloc' fbutils.o: In function `open_framebuffer': fbutils.c:(.text+0x9f4): undefined reference to `rpl_malloc' collect2: ld returned 1 exit status make[2]: *** [ts_test] 错误 1 make[2]:正在离开目录 `/home/zhuandi/programs/tslib1.4/tslib/tests' make[1]: *** [all-recursive] 错误 1 make[1]:正在离开目录 `/home/zhuandi/programs/tslib1.4/tslib' make: *** [all] 错误 2
解决:删除空格即可。# ./autogen.sh # echo "ac_cv_func_malloc_0 _nonnull=yes">arm-none-linux-gnueabi.cache
(2)第9步测试校准程序或其他程序时出现错误:egmentaton fault
原因:修改ts.conf时去掉注释符号时,留下空格。
解决:删除空格即可。
(3)第9步测试校准程序或其他程序时出现错误:触摸屏能显示,但对其操作无反应。
原因:网络上一参考博文的环境配置,其中没有export QWS_MOUSE_PROTO=tslib:/dev/input/event1
解决:环境变量加上export QWS_MOUSE_PROTO=tslib:/dev/input/event1 ,重启板子即可。