天嵌 ARM开发社区

 找回密码
 注册
查看: 4958|回复: 3

QT4.5.3和Tslib1.4移植

[复制链接]
TQ-lkp 发表于 2011-12-29 17:15:43 | 显示全部楼层 |阅读模式
本帖最后由 TQ-lkp 于 2011-12-29 17:17 编辑

原文地址:http://blog.163.com/zhouhui_1102/blog/static/150480748201171115215531/

首先,先说明下为了移植qt-embedded-linux-opensource-src-4.5.3,我主要参考了我博客里面转的一篇《Qt Embedded 4.5.3 的移植和触摸屏校正 》(http://blog.163.com/zhouhui_1102/blog/static/15048074820117235358115/),这篇里面的东西很是经典,个人认为前1,2,3点可以主要参考,我并没有参考第4点,第4点不够精炼。

      我曾一度为在TQ2440板子上运行QT程序出现segmentation fault(段错误)而烦恼,不过经过两三天的反复查阅资料,顺利的解决了。这篇博文主要是将我的移植方法和方式以及出现的棘手问题贴出来。

1、系统环境

操作系统:宿主机为WIN XP SP3,虚拟机运行Linux,版本为CentOS_5.5

Linux下编译器:gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)

交叉编译器:arm-linux-(4.1.2)

软件包:

qt-embedded-linux-opensource-src-4.5.3.tar.gz

arm920t-eabi.tgz(4.1.2的交叉编译器)

tslib-1.4.tar.gz(用于触摸验证)

2、编译安装——arm920t-eabi.tgz(4.1.2的交叉编译器)

这里需要注意!这个交叉编译器是别人编译好的,一定要解压成默认路径,不然会出现是用链接的编译器 4.1.2 编译qt4.5.3,./configure 能过,make就过不了了,有如下错误:
<built-in>:0: note: candidates are: void* operator new(unsigned int)
make[1]: *** [.pch/release-shared-emb-arm/QtCore.gch/c++] error 1
make[1]: Leaving directory `/opt/qte-4.5.2/src/corelib'
make: *** [sub-corelib-make_default-ordered] error 2

所以,正确的方式是tar xzf arm920t-eabi.tgz -C /
3、编译安装以及移植——qt-embedded-linux-opensource-src-4.5.3及tslib-1.4

这里我就不说x86的QT编译安装了,x86编译安装主要是为了一个qvfb(用于仿真开发板,提供一个嵌入式的运行环境)。主要还是参考我前面提到的那篇博文。

直接开始说明如何编译qt-embedded-linux-opensource-src-4.5.3,

先用tar xzf qt-embedded-linux-opensource-src-4.5.3.tar.gz解压到当前目录,

然后mv qt-embedded-linux-opensource-src-4.5.3 qte-arm 来修改目录名,

然后mv qte-arm /opt/,移动到/opt下,

再tar  xzf tslib-1.4.tar.gz解压到当前目录,

cd tslib/ ,执行./autogen.sh ,

再执行./configure --prefix=/usr/local/qte-arm/tslib-1.4 --host=arm-linux ac_cv_func_malloc_0_nonnull=yes ,

cd /opt/qte-arm,

再执行./configure --prefix=/opt/qte-arm/tslib-1.4 --host=arm-linux ac_cv_func_malloc_0_nonnull=yes ,
cd /opt/qte-arm,执行./configure -prefix /opt/qte-arm -no-qt3support -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -make libs -nomake examples -nomake demos -nomake docs -no-nis -no-cups -no-iconv -xplatform qws/linux-arm-g++ -embedded arm -little-endian -qt-freetype  -depths 8,16,24,32 -qt-gfx-linuxfb -no-gfx-transformed -no-gfx-qvfb -no-gfx-vnc -no-gfx-multiscreen -qt-kbd-usb -qt-kbd-tty -qt-mouse-pc -no-glib -qt-mouse-tslib -I/opt/qte-arm/tslib-1.4/include -L/opt/qte-arm/tslib-1.4/lib

没错误后,make,

然后,make install。

安装完毕,现在开始移植。

将qte-arm/下的lib/和plugins/考到开发板文件系统中的/opt/qt-4.5/下然后在此文件夹下mkdir bin。这里的bin文件夹可以放你编译完成的QT程序。

然后在qte-arm/tslib-1.4/bin下的ts_calibrate 拷贝到文件系统的sbin/下,拷贝qte-arm/tslib-1.4/etc/ts_conf到文件系统的/etc下然后修改ts_conf为以下内容:

module_raw input module pthres pmin=1  module variance delta=30  module dejitter delta=100  module linear  

记住这里必须顶格!不然会出现错误。


 楼主| TQ-lkp 发表于 2011-12-29 17:16:31 | 显示全部楼层
本帖最后由 TQ-lkp 于 2011-12-29 17:17 编辑

4、设置环境变量

设置文件系统中的/etc/profile下的内容如下:
export HOME=/root
export QTDIR=/opt/qt-4.5
export QPEDIR=/opt/qt-4.5
export QWS_DISPLAY="LinuxFB:/dev/fb0"
export QWS_DISPLAY="LinuxFB:mmWidth130:mmHeight100:0"
export QWS_KEYBOARD="TTY:/dev/tty1"
export TSLIB_TSDEVICE=/dev/event0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export QWS_MOUSE_PROTO="TSLIB:/dev/event0 Intellimouse:/dev/mouse0"
export QT_PLUGIN_PATH=$QTDIR/plugins/
export QT_QWS_FONTDIR=$QTDIR/lib/fonts/
export PATH=$QPEDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/plugins/imageformats:$LD_LIBRARY_PATH

然后source一下,让其生效。
再在文件系统bin下建立一个qt4.5的文件。touch qt4.5 ,chmod +x qt4.5。然后设置内容如下:

#!/bin/sh

echo Start Qt-4.5 > /dev/zh2440_serial0
export set HOME=/root
export set QTDIR=/opt/qt-4.5
export set QPEDIR=/opt/qt-4.5
export set QWS_DISPLAY="LinuxFB:/dev/fb0"
export set QWS_DISPLAY="LinuxFB:mmWidth130:mmHeight100:0"
export set QWS_KEYBOARD="TTY:/dev/tty1"
export set TSLIB_TSDEVICE=/dev/event0
export set TSLIB_CALIBFILE=/etc/pointercal
export set TSLIB_CONFFILE=/etc/ts.conf
export set TSLIB_PLUGINDIR=/lib/ts
export set QWS_MOUSE_PROTO="TSLIB:/dev/event0 Intellimouse:/dev/mouse0"
export set QT_PLUGIN_PATH=$QTDIR/plugins/
export set QT_QWS_FONTDIR=$QTDIR/lib/fonts/
export set PATH=$QPEDIR/bin:$PATH
export set LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/plugins/imageformats:$LD_LIBRARY_PATH

if [ -f /etc/pointercal ] ; then
echo Do not need start ts_calibrate! > /dev/zh2440_serial0
else
ts_calibrate
echo Start ts_calibrate > /dev/zh2440_serial0
fi

然后在文件系统下的/etc/init.d/rcS文件中加入qt4.5 &

到此文件系统设置结束。

回到虚拟机Linux下,gedit ~/.bashrc ,设置内容如下:

alias qvfb='/opt/qte-x86/bin/qvfb -width 640 -height 480'  
alias qte-x86-make='/opt/qte-x86/bin/qmake'  
alias qte-arm-make='/opt/qte-arm/bin/qmake'  
alias qtx86-make='/opt/qt-x86/bin/qmake'

这里有些是移植了x86的东西,具体看我前面提到的博文。然后source下。

最后到你的工程文件夹下,依次执行 qte-arm-make -project,qte-arm-make ,make。然后产生的执行文件可以cp到你的文件系统下,假设这里的执行文件为helloworld。

到开发板环境下执行:./helloworld -qws 成功。

5、几点致命而又经典错误

(1)segmentation fault

段错误出现在你在开发板环境下执行./helloworld -qws 出现。主要原因是因为你的交叉编译器版本问题。这里推荐4.1.2版本,需注意QT和QT程序需同一个交叉编译器来编译。我在这个错误上痛苦了很久,因为之前我一直用4.3.3的交叉编译器,导致总是出现这个错误。

下面是对这个错误不同网友的理解:

1)、界面是否出超出开发板的屏幕大小
2)、这个是编译器问题,在qtcenter上有说到4.3的优化太厉害,解决方法有3种:
a、把工程的makefile的cflag选项的O2降为O1,我直接降为-g,不过编译的程序就比较大了
b、换成4.1以下的编译器
c、修改qt的文件,具体忘了 :( 可以去搜索一下。

3)、核2.6.29的不能用4.1.1以下的了。

(2)用4.1.2编译QT程序的错误

usr/local/arm/4.1.2/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/../../../../arm-angstrom-linux-gnueabi/bin/ld: warning: libts-0.0.so.0, needed by /home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so, not found (try using -rpath or -rpath-link)
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_read_raw'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_open'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_fd'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_config'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_close'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_read'
collect2: ld returned 1 exit status
make[2]: *** [deform] Error 1
make[2]: Leaving directory `/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/demos/deform'
make[1]: *** [sub-deform-make_default] Error 2
make[1]: Leaving directory `/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/demos'
make: *** [sub-demos-make_default-ordered] Error 2

解决办法:
修改qt-everywhere-opensource-src-4.6.0/mkspecs/qws/linux-arm-g++/qmake.conf 文件(添加lts参数):
QMAKE_CC                = arm-linux-gcc -lts
QMAKE_CXX               = arm-linux-g++ -lts
QMAKE_LINK              = arm-linux-g++ -lts
QMAKE_LINK_SHLIB        = arm-linux-g++ -lts

(3)4.1.2没有移植库的错误

我的文件系统中的库文件基本上都是4.3.3编译器的,所以运行QT程序的时候会出现下面错误:

[root@zh2440 /home]# ./helloworld -qws
./helloworld: error while loading shared libraries: libts-1.0.so.0: cannot open shared object file: No such file or

directory

解决办法:从4.1.2的交叉编译器文件lib/libts-1.0.so.0下拷到文件系统中

小七战士 发表于 2012-2-16 03:57:50 | 显示全部楼层
真是好东西,顶啊!











我心永恒00 发表于 2012-12-28 19:46:49 | 显示全部楼层
#define S3C2410TSVERSION        0x0101
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-4-20 11:29 , Processed in 1.062493 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表