你好,游客 登录 注册 搜索
背景:
阅读新闻

Tslib和Qt 4.8.4与在开发板上的移植

[日期:2014-04-08] 来源:Linux社区  作者:emouse [字体:大 中 小]

QT 的交叉编译与安装

和PC平台下的编译类似,通过运行./configure进行配置生成makefile文件,然后编译安装,只是因为是针对嵌入式平台需要进行一些针对性配置,这里生成一个自动配置文件,可以通过修改文件来方便的更改配置。

# cd qt-everywhere-opensource-src-4.8.4
#sudo gedit autoconfig.sh

加入以下内容保存.

 
#!/bin/sh
./configure -opensource -confirm-license -release -shared -embedded arm -xplatform qws/linux-arm-g++-depths 16,18,24-fast -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -little-endian -host-little-endian -no-qt3support -no-libtiff -no-libmng -no-opengl -no-mmx -no-sse -no-sse2 -no-3dnow -no-openssl -no-webkit -no-qvfb -no-phonon -no-nis -no-opengl -no-cups -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -nomake examples -nomake tools -nomake docs -qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib exit
 

文件中的内容就是需要配置的内容,同样如果需要指定安装路径可以在开始加入-prefix=/usr/local/(自己的路径)

上面的主要参数含义说明如下:
-embedded arm: 表示将编译针对 arm 平台的 embedded 版本;
-xplatform qws/linux-arm-g++: 表示使用 arm-linux 交叉编译器进行编译;
-qt-mouse-tslib: 表示将使用 tslib 来驱动触摸屏;

其他还有很多参数我也不太了解,后面使用的过程中再慢慢体会.

运行./autoconfig.sh 生成makefile文件,生成成功最后会输出如下信息

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/Trolltech/QtEmbedded-4.8.4-arm

To reconfigure, run 'make confclean' and 'configure'.

如果编译出现缺少链接信息错误:

 
warning: libts-0.0.so.0, needed by , not found (try using -rpath or -rpath-link)
undefined reference to `ts_read_raw'
undefined reference to `ts_open'
undefined reference to `ts_fd'
undefined reference to `ts_config'
undefined reference to `ts_close'
undefined reference to `ts_read'
collect2: ld returned 1 exit status
 

解决方法如下:

修改qt-everywhere-opensource-src-4.8.4/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

修改完成后保存退出,继续编译。

这段信息指明了安装方式和默认路径,所以可以看出不指定路径情况下的默认安装路径,因此这个路径没必要手工指定,虽然查出来的资料都指定的。

接下来执行make 进行编译,时间同样需要很长的时间,视个人电脑配置而定,时间大概在半个小时左右吧。

最后make install安装,安装完成后可以在安装目录/usr/local/Trolltech/QtEmbedded-4.8.4-arm 下查看对应文件。

开发板配置

在开发板上的使用其实很简单,只需要拷贝相应的库文件并设置环境变量即可,拷贝的方法按照个人喜好,我是挂载nfs来实现拷贝。

root@emouse:/armnfs# cp -R /usr/local/Trolltech/QtEmbedded-4.8.4-arm/lib /armnfs/qt

设置环境变量:

export QTDIR=/opt/qt484 
export LD_LIBRARY_PATH=$QTDIRlib:$LD_LIBRARY_PATH 
export PATH=$QTDIR/bin:$PATH 
export QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen0 
export QWS_DISPLAY="LinuxFb:mmWidth100:mmHeight130:0" 
export QT_QWS_FONTDIR=/opt/qt484/lib/fonts

在飞凌的OK6410板子中,是在/bin目录下放一个脚本文件,在脚本文件中设置变量来实现运行,这样可以为不同的程序进行单独的配置,也可以设置开机运行等,用起来比较方便,下面是我的脚本文件,脚本中完成对所有环节变量的配置,当然这里是基于之前的改的,所以有些是多余的。最后运行的程序就是我放在opt目录下的QC程序。关于在开发板上的Qt程序中显示中文字体等设置可以参见 Qt 中显示中文 这篇博客 http://www.linuxidc.com/Linux/2014-04/99757.htm。

 
#!/bin/sh
base1=qpe
pid=`/bin/pidof $base1`
if [ -n "$pid" ]; then
    killall $base1
fi

base2=qss
pid=`/bin/pidof $base2`
if [ -n "$pid" ]; then
    killall $base2
fi

base3=quicklauncher
pid=`/bin/pidof $base3`
if [ -n "$pid" ]; then
    killall  $base3
fi


base4=fluidlauncher
pid=`/bin/pidof $base4`
if [ -n "$pid" ]; then
    killall  $base4
fi

export TSLIB_ROOT=/usr/local/tslib
export TSLIB_TSDEVICE=/dev/input/event2
export TSLIB_TSEVENTTYPE=H3600
export TSLIB_CONFFILE=/usr/local/tslib/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export QTDIR=/opt/qt-4.8.4/
export QT_QWS_FONTDIR=/opt/qt-4.8.4/lib/fonts

export LD_LIBRARY_PATH=$QTDIR/plugins/qtopialmigrate/:$QTDIR/qt_plugins/imageformats/:$QTDIR/lib:/root/tslib/build/lib:$LD_LIBRARY_PATH
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin:/root/tslib/build/bin


if [ -c /dev/input/event2 ]; then
        export QWS_MOUSE_PROTO="Tslib:${TSLIB_TSDEVICE}"
        if [ -e /etc/pointercal -a ! -s /etc/pointercal ] ; then
                rm /etc/pointercal
                /root/tslib/build/bin/ts_calibrate
        fi
else
        export QWS_MOUSE_PROTO="MouseMan:/dev/input/mice"
        >/etc/pointercal
fi
export QWS_KEYBOARD=TTY:/dev/tty1



FB_SIZE=$(cat /sys/class/graphics/fb0/virtual_size)

#export QWS_DISPLAY="LinuxFb:mmWidth76:mmHeight44:1"
case "$FB_SIZE" in
800,480)
export QWS_DISPLAY="LinuxFb:mmWidth91:mmHeight53:1"
;;
480,272)
export QWS_DISPLAY="LinuxFb:mmWidth76:mmHeight44:1"
;;
*)
export QWS_DISPLAY="LinuxFb:mmWidth91:mmHeight53:1"
;;
esac
#export QWS_DISPLAY=:1



export HOME=/root/QtE4Home

cd /opt
./QC -qws
linux
相关资讯       Qt 4.8.4  Tslib移植  Qt开发板 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款