Loongson 1B板上移植QT-3及环境搭建(带TSLIB触摸屏支持)

目录

一、文档简介: 4

二、移植过程 4

1.安装交叉编译工具链 4

2.交叉编译TSLIB工具 4

3.交叉编译QT3 5

4.QT程序移植及运行环境配置 21

一、文档简介:

本文档用于介绍Loongson1B开发板上移植QT-3以及相关运行环境的搭建。

开发环境参数:

操作系统:Ubuntu11.04

本机平台:X86

目标平台:Loongson1B开发板

交叉编译工具链:gcc-3.4.6-2f1B交叉编译工具链)

所需软件及工具包:

QT源码包:qt-embedded-free-3.3.7.tar.gz

TSLIB源码包:tslib-1.4.tar.gz

二、移植过程

1.安装交叉编译工具链

首先安装Loongson1B开发板提供的交叉编译工具链:

解压gcc-3.4.6-2f.tar.gz。PS.有些工具链对目录有一定的要求,请询问交叉编译工具链提供者,gcc-3.4.6-2f需要放在/home/cpu/目录下面。

#tarzxvfgcc-3.4.6-2f.tar.gz

#mvgcc-3.4.6-2f/home/cpu/

将工具链加入到PATH环境变量中:

#exportPATH=/home/cpu/gcc-3.4.6-2f/bin:$PATH

PS.每一次需要交叉编译均需要将交叉编译工具链加入到PATH变量,可通过修改/etc/profile文件来实现默认添加,即将上边最后一条语句加入到该文件中即可。

2.交叉编译TSLIB工具

解压tslib-1.4.tar.gz,进入文件夹交叉编译TSLIB工具,并指定工具安装目录为/TSLIB

#tarzxvftslib-1.4.tar.gz

#cdtslib-1.4

#./autogen.sh

#./configure--host=mipsel-linuxac_cv_func_malloc_0_nonnull=yes

--prefix=/TSLIB

#make

#makeinstall

编译完成后,TSLIB目录需包含以下文件目录:

#ls/TSLIB

binetcincludelib

各个目录分别为TSLIB的校准及测试程序、环境配置文件、头文件、动态库。

根据1B开发板触摸屏驱动类型,配置TSLIB,修改TSLIB的环境配置文件:修改/TSLIB/etc/ts.conf,将#module_rawinput改成module_rawinput,即去掉前面的注释符。PS.这里需要注意的是module_rawinput前面不允许有空格。

3.交叉编译QT3

首先解压QT-3.3.7源码包并重命名后进入改目录以配置环境变量:

#tarzxvfqt-embedded-free-3.3.7.tar.gz

#mvqt-embedded-free-3.3.7/qt-embedded-free-3.3.7-tslib-test

#cdqt-embedded-free-3.3.7-tslib-test/

#exportQTDIR=$PWD

#exportQTEDIR=$PWD

#exportLD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

#exportPATH=$QTDIR/bin:$PATH

执行以上步骤即可配置好QT的编译环境变量。

接下来需要修改相关的QT编译参数:

#vimmkspecs/qws/linux-mips-g++/qmake.conf

确保文件中指定的交叉编译参数为gcc-3.4.6-2f交叉编译工具链中对应gcc名称。主要修改以下标记为yellow的参数:

File:mkspecs/qws/linux-mips-g++/qmake.conf

#

#$Id:qt/qmake.conf3.3.7editedMay272003$

#

#qmakeconfigurationforlinux-g++usingthemipsel-linux-g++crosscompiler

#

MAKEFILE_GENERATOR =UNIX

TEMPLATE =app

CONFIG +=qtlink_prl

QMAKE_CC =mipsel-linux-gcc

QMAKE_LEX =flex

QMAKE_LEXFLAGS =

QMAKE_YACC =yacc

QMAKE_YACCFLAGS =-d

QMAKE_CFLAGS =-pipe

QMAKE_CFLAGS_WARN_ON =-Wall-W

QMAKE_CFLAGS_WARN_OFF =

QMAKE_CFLAGS_RELEASE =-O2

QMAKE_CFLAGS_DEBUG =-g

QMAKE_CFLAGS_SHLIB =-fPIC

QMAKE_CFLAGS_YACC =-Wno-unused-Wno-parentheses

QMAKE_CFLAGS_THREAD =-D_REENTRANT

QMAKE_CXX =mipsel-linux-g++

QMAKE_CXXFLAGS =$$QMAKE_CFLAGS-DQWS-fno-exceptions-fno-rtti

QMAKE_CXXFLAGS_WARN_ON =$$QMAKE_CFLAGS_WARN_ON

QMAKE_CXXFLAGS_WARN_OFF =$$QMAKE_CFLAGS_WARN_OFF

QMAKE_CXXFLAGS_RELEASE =$$QMAKE_CFLAGS_RELEASE

QMAKE_CXXFLAGS_DEBUG =$$QMAKE_CFLAGS_DEBUG

QMAKE_CXXFLAGS_SHLIB =$$QMAKE_CFLAGS_SHLIB

QMAKE_CXXFLAGS_YACC =$$QMAKE_CFLAGS_YACC

QMAKE_CXXFLAGS_THREAD =$$QMAKE_CFLAGS_THREAD

QMAKE_INCDIR =

QMAKE_LIBDIR =

QMAKE_INCDIR_X11 =

QMAKE_LIBDIR_X11 =

QMAKE_INCDIR_QT =$(QTDIR)/include

QMAKE_LIBDIR_QT =$(QTDIR)/lib

QMAKE_INCDIR_OPENGL =/usr/X11R6/include

QMAKE_LIBDIR_OPENGL =/usr/X11R6/lib

QMAKE_INCDIR_QTOPIA =$(QPEDIR)/include

QMAKE_LIBDIR_QTOPIA =$(QPEDIR)/lib

QMAKE_LINK =mipsel-linux-g++

QMAKE_LINK_SHLIB =mipsel-linux-g++

QMAKE_LFLAGS =

QMAKE_LFLAGS_RELEASE =

QMAKE_LFLAGS_DEBUG =

QMAKE_LFLAGS_SHLIB=-shared

QMAKE_LFLAGS_PLUGIN=$$QMAKE_LFLAGS_SHLIB

QMAKE_LFLAGS_SONAME=-Wl,-soname,

QMAKE_LFLAGS_THREAD=

QMAKE_RPATH=-Wl,-rpath,

QMAKE_LIBS =

QMAKE_LIBS_DYNLOAD=-ldl

QMAKE_LIBS_X11 =

QMAKE_LIBS_X11SM =

QMAKE_LIBS_QT =-lqte

QMAKE_LIBS_QT_THREAD=-lqte-mt

QMAKE_LIBS_QT_OPENGL =-lqgl

QMAKE_LIBS_QTOPIA =-lqtopia-lqpe

QMAKE_LIBS_THREAD=-lpthread

QMAKE_MOC =$(QTDIR)/bin/moc

QMAKE_UIC =$(QTDIR)/bin/uic

QMAKE_AR =arcqs

QMAKE_RANLIB =

QMAKE_TAR =tar-cf

QMAKE_GZIP =gzip-9f

QMAKE_COPY =cp-f

QMAKE_MOVE =mv-f

QMAKE_DEL_FILE =rm-f

QMAKE_DEL_DIR =rmdir

QMAKE_CHK_DIR_EXISTS =test-d

QMAKE_MKDIR =mkdir-p

接下来需要为QT-3添加TSLIB触摸屏支持,对源码包进行部分修改:

首先修改src/tools/qconfig-local.h文件(不存在此文件可在该目录下创建一个同名空文件),添加触摸屏支持:

File:src/tools/qconfig-local.h

#ifndefQT_H

#endif

#ifndefQT_DLL

#defineQT_DLL

#endif

#defineQT_QWS_IPAQ

#defineQT_QWS_IPAQ_RAW

#defineQT_NO_QWS_CURSOR

#defineQT_NO_QWS_MOUSE_AUTO

然后添加TSLIB补丁,增加QT-3TSLIB触摸屏校正支持:

QTDIR所在的上层目录创建一个名为tslib.patch的文件,文件内容如下:

File:../tslib.patch

Index:qt-embedded-free-3.3.4-orig/src/embedded/qmousetslib_qws.h

===================================================================

---/dev/null 1970-01-0100:00:00.000000000+0000

+++qt-embedded-free-3.3.4-orig/src/embedded/qmousetslib_qws.h 2005-02-1821:42:13.000000000-0800

@@-0,0+1,57@@

+/****************************************************************************

+**$Id$

+**

+**DefinitionofQt/Embeddedmousedriver

+**

+**Created:20020220

+**

+**Copyright(C)1992-2002TrolltechAS.Allrightsreserved.

+**

+**ThisfileispartofthekernelmoduleoftheQtGUIToolkit.

+**

+**Thisfilemaybedistributedand/ormodifiedunderthetermsofthe

+**GNUGeneralPublicLicenseversion2aspublishedbytheFreeSoftware

+**FoundationandappearinginthefileLICENSE.GPLincludedinthe

+**packagingofthisfile.

+**

+**LicenseesholdingvalidQtEnterpriseEditionorQtProfessionalEdition

+**licensesforQt/Embeddedmayusethisfileinaccordancewiththe

+**QtEmbeddedCommercialLicenseAgreementprovidedwiththeSoftware.

+**

+**ThisfileisprovidedASISwithNOWARRANTYOFANYKIND,INCLUDINGTHE

+**WARRANTYOFDESIGN,MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE.

+**

+**Seehttp://www.trolltech.com/pricing.htmloremailsales@trolltech.comfor

+**informationaboutQtCommercialLicenseAgreements.

+**Seehttp://www.trolltech.com/gpl/forGPLlicensinginformation.

+**

+**Contactinfo@trolltech.comifanyconditionsofthislicensingare

+**notcleartoyou.

+**

+**********************************************************************/

+

+#ifndefQMOUSETSLIB_QWS_H

+#defineQMOUSETSLIB_QWS_H

+

+#ifndefQT_H

+#include"qmouse_qws.h"

+#endif//QT_H

+

+#ifndefQT_NO_QWS_MOUSE_TSLIB

+

+classQWSTSLibMouseHandlerPrivate;

+

+classQWSTSLibMouseHandler:publicQWSCalibratedMouseHandler

+{

+public:

+QWSTSLibMouseHandler(constQString&=QString::null,constQString&=QString::null);

+~QWSTSLibMouseHandler();

+

+protected:

+QWSTSLibMouseHandlerPrivate*d;

+};

+

+#endif

+

+#endif

+

Index:qt-embedded-free-3.3.4-orig/src/embedded/qmousetslib_qws.cpp

===================================================================

---/dev/null 1970-01-0100:00:00.000000000+0000

+++qt-embedded-free-3.3.4-orig/src/embedded/qmousetslib_qws.cpp 2005-02-1912:00:29.000000000-0800

@@-0,0+1,354@@

+/****************************************************************************

+**$Id$

+**

+**ImplementationofQt/Embeddedmousedrivers

+**

+**Copyright(C)1992-2000TrolltechAS.Allrightsreserved.

+**

+**ThisfileispartofthekernelmoduleoftheQtGUIToolkit.

+**

+**Thisfilemaybedistributedand/ormodifiedunderthetermsofthe

+**GNUGeneralPublicLicenseversion2aspublishedbytheFreeSoftware

+**FoundationandappearinginthefileLICENSE.GPLincludedinthe

+**packagingofthisfile.

+**

+**LicenseesholdingvalidQtEnterpriseEditionorQtProfessionalEdition

+**licensesforQt/Embeddedmayusethisfileinaccordancewiththe

+**QtEmbeddedCommercialLicenseAgreementprovidedwiththeSoftware.

+**

+**ThisfileisprovidedASISwithNOWARRANTYOFANYKIND,INCLUDINGTHE

+**WARRANTYOFDESIGN,MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE.

+**

+**Seehttp://www.trolltech.com/pricing.htmloremailsales@trolltech.comfor

+**informationaboutQtCommercialLicenseAgreements.

+**Seehttp://www.trolltech.com/gpl/forGPLlicensinginformation.

+**

+**Contactinfo@trolltech.comifanyconditionsofthislicensingare

+**notcleartoyou.

+**

+**********************************************************************/

+

+#include"qmousetslib_qws.h"

+

+#ifndefQT_NO_QWS_MOUSE_TSLIB

+#include"qwindowsystem_qws.h"

+#include"qsocketnotifier.h"

+#include"qtimer.h"

+#include"qapplication.h"

+#include"qgfx_qws.h"

+

+#include<unistd.h>

+#include<stdlib.h>

+#include<stdio.h>

+#include<sys/ioctl.h>

+#include<sys/types.h>

+#include<sys/stat.h>

+#include<fcntl.h>

+#include<errno.h>

+#include<termios.h>

+

+#include<tslib.h>

+

+#ifndefQT_QWS_TP_SAMPLE_SIZE

+#defineQT_QWS_TP_SAMPLE_SIZE5

+#endif

+

+#ifndefQT_QWS_TP_MINIMUM_SAMPLES

+#defineQT_QWS_TP_MINIMUM_SAMPLES5

+#endif

+

+#ifndefQT_QWS_TP_PRESSURE_THRESHOLD

+#defineQT_QWS_TP_PRESSURE_THRESHOLD1

+#endif

+

+#ifndefQT_QWS_TP_MOVE_LIMIT

+#defineQT_QWS_TP_MOVE_LIMIT100

+#endif

+

+#ifndefQT_QWS_TP_JITTER_LIMIT

+#defineQT_QWS_TP_JITTER_LIMIT2

+#endif

+

+//#defineQWS_CUSTOMTOUCHPANEL

+

+

+/*

+mousehandlerfortslib

+seehttp://cvs.arm.linux.org.uk/

+*/

+/*

+

+Copyright(C)2003,2004,2005TexasInstruments,Inc.

+Copyright(C)2004,2005HolgerHansPeterFreyther

+Allrightsreserved.

+

+Redistributionanduseinsourceandbinaryforms,withorwithout

+modification,arepermittedprovidedthatthefollowingconditionsaremet:

+

+Redistributionsofsourcecodemustretaintheabovecopyrightnotice,

+thislistofconditionsandthefollowingdisclaimer.

+

+Redistributionsinbinaryformmustreproducetheabovecopyright

+notice,thislistofconditionsandthefollowingdisclaimerinthe

+documentationand/orothermaterialsprovidedwiththedistribution.

+

+NeitherthenameTexasInstruments,Incnorthenamesofits

+contributorsmaybeusedtoendorseorpromoteproductsderived

+fromthissoftwarewithoutspecificpriorwrittenpermission.

+

+THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS

+"ASIS"ANDANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOT

+LIMITEDTO,THEIMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESS

+FORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALLTHE

+COPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,

+INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES

+(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODSOR

+SERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)

+HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,

+STRICTLIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISING

+INANYWAYOUTOFTHEUSEOFTHISSOFTWARE,EVENIFADVISEDOFTHE

+POSSIBILITYOFSUCHDAMAGE.

+

+*/

+classQWSTSLibMouseHandlerPrivate:publicQObject

+{

+Q_OBJECT

+public:

+QWSTSLibMouseHandlerPrivate(QWSTSLibMouseHandler*h,

+ constQString&device);

+~QWSTSLibMouseHandlerPrivate(){closeTs();}

+

+//virtualvoidclearCalibration();

+//virtualvoidcalibrate(QWSPointerCalibrationData*);

+staticintsortByX(constvoid*,constvoid*);

+staticintsortByY(constvoid*,constvoid*);

+

+private:

+boolm_raw:1;

+QSocketNotifier*m_notify;

+QWSTSLibMouseHandler*handler;

+

+structtsdev*m_ts;

+voidopenTs(constQString&device);

+voidcloseTs(void);

+voidinterpolateSample();

+

+privateslots:

+voidreadMouseData();

+

+};

+

+QWSTSLibMouseHandler::QWSTSLibMouseHandler(constQString&protocol,

+ constQString&device)

+{

+qDebug("%s:handlerinit%s%s",__FUNCTION__,

+ (constchar*)protocol,(constchar*)device);

+

+d=newQWSTSLibMouseHandlerPrivate(this,device);

+}

+

+QWSTSLibMouseHandler::~QWSTSLibMouseHandler()

+{

+deleted;

+}

+

+QWSTSLibMouseHandlerPrivate::QWSTSLibMouseHandlerPrivate

+ (QWSTSLibMouseHandler*h,constQString&device)

+:m_raw(false),m_notify(0),handler(h)

+{

+qDebug("%s:init%s",__FUNCTION__,(constchar*)device);

+openTs(device);

+}

+

+voidQWSTSLibMouseHandlerPrivate::openTs(constQString&device)

+{

+qDebug("%s:castdevice",__FUNCTION__);

+

+constchar*tsdevice=device.isEmpty()?NULL:device;

+

+qDebug("%s:device%s",__FUNCTION__,tsdevice);

+

+if(tsdevice==NULL)

+tsdevice=getenv("TSLIB_TSDEVICE");

+if(tsdevice==NULL)

+tsdevice="/dev/ts";

+

+qDebug("%s:device%s",__FUNCTION__,tsdevice);

+

+m_ts=::ts_open(tsdevice,1);//1=nonblocking,0=blockingmode

+

+qDebug("%s:m_ts%p",__FUNCTION__,m_ts);

+

+if(!m_ts){

+qWarning("Cannotopentouchscreen(%s)",strerror(errno));

+return;

+}

+

+if(ts_config(m_ts)){

+qWarning("Cannotconfiguretouchscreen(%s)",strerror(errno));

+return;

+}

+m_notify=newQSocketNotifier(ts_fd(m_ts),QSocketNotifier::Read,this);

+connect(m_notify,SIGNAL(activated(int)),this,SLOT(readMouseData()));

+}

+

+voidQWSTSLibMouseHandlerPrivate::closeTs()

+{

+if(m_ts)

+ts_close(m_ts);

+m_ts=0;

+

+deletem_notify;

+m_notify=0;

+m_raw=false;

+}

+

+#if0

+voidQWSTSLibMouseHandlerPrivate::clearCalibration()

+{

+m_raw=true;

+}

+

+voidQWSTSLibMouseHandlerPrivate::calibrate(QWSPointerCalibrationData*cd)

+{

+QPointdev_tl=cd->devPoints[QWSPointerCalibrationData::TopLeft];

+QPointdev_br=cd->devPoints[QWSPointerCalibrationData::BottomRight];

+QPointscreen_tl=cd->screenPoints[QWSPointerCalibrationData::TopLeft];

+QPointscreen_br=cd->screenPoints[QWSPointerCalibrationData::BottomRight];

+inta,b,c,d,e,f,s;

+

+s=1<<16;

+

+a=s*(screen_tl.x()-screen_br.x())/(dev_tl.x()-dev_br.x());

+b=0;

+c=s*screen_tl.x()-a*dev_tl.x();

+

+d=0;

+e=s*(screen_tl.y()-screen_br.y())/(dev_tl.y()-dev_br.y());

+f=s*screen_tl.y()-e*dev_tl.y();

+

+QStringcalFile="/etc/pointercal";

+#ifndefQT_NO_TEXTSTREAM

+QFilefile(calFile);

+if(file.open(IO_WriteOnly)){

+QTextStreamt(&file);

+t<<a<<""<<b<<""<<c<<"";

+t<<d<<""<<e<<""<<f<<""<<s;

+file.flush();closeTs();

+openTs();

+}else

+#endif

+{

+qDebug("Couldnotsavecalibration:%s",calFile.latin1());

+}

+}

+#endif

+

+voidQWSTSLibMouseHandlerPrivate::readMouseData()

+{

+if(!qt_screen)

+return;

+

+/*

+*AfterclearCalibration

+*we'reinrawmodeanddosomeeasymedian

+*search.

+*/

+if(m_raw)

+returninterpolateSample();

+

+staticstructts_samplesample;

+staticintret;

+

+/*

+*Ok.Weneedtoseeifwecanreadmorethanoneevent

+*Wedothisnottoloseanupdate.

+*/

+while(true){

+if((ret=ts_read(m_ts,&sample,1))!=1)

+return;

+

+

+QPointpos(sample.x,sample.y);

+handler->mouseChanged(pos,sample.pressure!=0?1:0);

+}

+}

+

+/*

+*Letstakealldowneventsandthensortthem

+*andtaketheeventinthemiddle.

+*

+*inspiredbytestutils.c

+*/

+voidQWSTSLibMouseHandlerPrivate::interpolateSample(){

+#ifdefQT_QWS_TSLIB

+#defineTSLIB_MAX_SAMPLES25

+staticstructts_samplesamples[TSLIB_MAX_SAMPLES];

+intindex=0;

+intread_samples=0;

+intret;

+

+do{

+/*donotaccessnegativearrays*/

+if(index<0)

+index=0;

+

+/*we'reopenednon-blocking*/

+if((ret=ts_read_raw(m_ts,&samples[index],1))!=1){

+/*noeventyet,sotryagain*/

+if(ret==-1){

+--index;

+continue;

+}else

+++read_samples;

+}

+}while(samples[(index++)%TSLIB_MAX_SAMPLES].pressure!=0);

+

+/*

+*Ifwe'vewrappedaroundeachsampleisusedotherwise

+*wewillusetheindex

+*/

+index=read_samples>=TSLIB_MAX_SAMPLES?

+(TSLIB_MAX_SAMPLES-1):index;

+intx,y;

+

+/*

+*nowletususethemedianvalue

+*evenindexdoesnothaveaniteminthemiddle

+*soletustaketheaverageofn/2and(n/2)-1asthemiddle

+*/

+intm=index/2;

+::qsort(samples,index,sizeof(ts_sample),QWSTSLibMouseHandlerPrivate::sortByX);

+x=(index%2)?samples[m].x:

+(samples[m-1].x+samples[m].x)/2;

+

+::qsort(samples,index,sizeof(ts_sample),QWSTSLibMouseHandlerPrivate::sortByY);

+y=(index%2)?samples[m].y:

+(samples[m-1].y+samples[m].y)/2;

+

+emithandler->mouseChanged(QPoint(x,y),1);

+emithandler->mouseChanged(QPoint(0,0),0);

+#endif

+}

+

+intQWSTSLibMouseHandlerPrivate::sortByX(constvoid*one,constvoid*two){

+#ifdefQT_QWS_TSLIB

+returnreinterpret_cast<conststructts_sample*>(one)->x-

+reinterpret_cast<conststructts_sample*>(two)->x;

+#else

+return0;

+#endif

+}

+

+intQWSTSLibMouseHandlerPrivate::sortByY(constvoid*one,constvoid*two){

+#ifdefQT_QWS_TSLIB

+returnreinterpret_cast<conststructts_sample*>(one)->y-

+reinterpret_cast<conststructts_sample*>(two)->y;

+#else

+return0;

+#endif

+}

+//

+

+#include"qmousetslib_qws.moc"

+#endif//QT_NO_QWS_MOUSE_TSLIB

Index:qt-embedded-free-3.3.4-orig/src/embedded/qmousedriverfactory_qws.cpp

===================================================================

---qt-embedded-free-3.3.4-orig.orig/src/embedded/qmousedriverfactory_qws.cpp 2005-01-2109:16:07.000000000-0800

+++qt-embedded-free-3.3.4-orig/src/embedded/qmousedriverfactory_qws.cpp 2005-02-2011:11:17.141669149-0800

@@-39,6+39,7@@

#include"qmousevr41xx_qws.h"

#include"qmouseyopy_qws.h"

#include"qmouselinuxtp_qws.h"

+#include"qmousetslib_qws.h"

#include<stdlib.h>

#if!defined(Q_OS_WIN32)||defined(QT_MAKEDLL)

@@-99,6+100,10@@

QWSMouseHandler*QMouseDriverFactory::create(constQString&key,constQString&device)

{

QStringdriver=key.lower();

+#ifndefQ_NO_QWS_MOUSE_TSLIB

+if(driver=="tslib"||driver.isEmpty())

+ returnnewQWSTSLibMouseHandler(key,device);

+#endif

#ifdefQ_OS_QNX6

if(driver=="qnx"||driver.isEmpty())

returnnewQWSQnxMouseHandler(key,device);

Index:qt-embedded-free-3.3.4-orig/src/embedded/qt_embedded.pri

===================================================================

---qt-embedded-free-3.3.4-orig.orig/src/embedded/qt_embedded.pri 2003-12-0102:16:53.000000000-0800

+++qt-embedded-free-3.3.4-orig/src/embedded/qt_embedded.pri 2005-02-1821:49:00.000000000-0800

@@-177,6+177,12@@

}

else:DEFINES+=QT_NO_QWS_MOUSE_LINUXTP

+ contains(mouse-drivers,tslib){

+ HEADERS+=$$EMBEDDED_H/qmousetslib_qws.h

+ SOURCES+=$$EMBEDDED_CPP/qmousetslib_qws.cpp

+ }

+ else:DEFINES+=QT_NO_QWS_MOUSE_TSLIB

+

contains(mouse-drivers,vr41xx){

HEADERS+=$$EMBEDDED_H/qmousevr41xx_qws.h

SOURCES+=$$EMBEDDED_CPP/qmousevr41xx_qws.cpp

Index:qt-embedded-free-3.3.4-orig/configure

===================================================================

---qt-embedded-free-3.3.4-orig.orig/configure 2004-10-1810:17:00.000000000-0700

+++qt-embedded-free-3.3.4-orig/configure 2005-02-1912:17:47.000000000-0800

@@-950,6+950,12@@

["$VAR"="style"]&&QMAKE_VARS="$QMAKE_VARS\"${VAR}s-=$VAL\""

VAR="${VAR}-${OPT}"

else

+ if["$VAR"="mouse"]&&["$VAL"="tslib"];then

+ QMAKE_CONFIG="$QMAKE_CONFIGtslib"

+ QMAKE_VARS="$QMAKE_VARS\"QMAKE_LIBDIR_FLAGS+=-lts\""

+ QMAKE_VARS="$QMAKE_VARS\"QMAKE_LIBS_QT+=-lts\""

+ QMAKE_VARS="$QMAKE_VARS\"QMAKE_LIBS_QT_THREAD+=-lts\""

+ fi

if["$VAR"="sql"]||["$VAR"="gfx"]||["$VAR"="kbd"]||["$VAR"="mouse"];then

VAR="${VAR}-driver"

fi

@@-2294,7+2300,7@@

-qt-mouse-<driver>.Enableamouse<driver>intheQtLibrary.

-no-mouse-<driver>.Disablemouse<driver>entirely.

-Possiblevaluesfor<driver>:[pcbuslinuxtpyopyvr41xx]

+Possiblevaluesfor<driver>:[pcbuslinuxtpyopyvr41xxtslib]

EOF

fi

@@-2887,6+2893,7@@

QMAKE_VARS="$QMAKE_VARS\"QMAKE_LIBS_QT+=-lz\""

QMAKE_VARS="$QMAKE_VARS\"QMAKE_LIBS_QT_THREAD+=-lz\""

fi

+

["$CFG_NIS"="yes"]&&QMAKE_CONFIG="$QMAKE_CONFIGnis"

["$CFG_CUPS"="yes"]&&QMAKE_CONFIG="$QMAKE_CONFIGcups"

["$CFG_NAS"="system"]&&QMAKE_CONFIG="$QMAKE_CONFIGnas"

然后在QTDIR内执行以下命令,为QT-3添加TSLIB触摸屏校正补丁:

#cd$QTDIR

#patch-p1<../tslib.patch

最后修改src/embedded/qmouselinuxtp_qws.cpp修正正确的触摸屏设备名称。

File:src/embedded/qmouselinuxtp_qws.cpp

#ifdef

QT_QWS_IPAQ_RAW

mouseFD=open("/dev/event0",O_RDONLY)

将双引号内的设备名称改为自己的触摸屏设备名,设备名由触摸屏驱动决定。

以上几个步骤完成了对QT-3添加触摸屏支持的相关配置,接下来开始进行QT-3的交叉编译过程:

#./configure-no-cups-xplatformqws/linux-mips-g++-embeddedmips-thread-no-stl-qt-mouse-tslib-I/TSLIB/include-L/TSLIB/lib-lts-depths4,8,16,32-qvfb-prefix/usr/local/Trolltech/QtEmbedded-3.3.7-mips/

#make

TheQtlibraryisnowbuiltin./lib

TheQtexamplesarebuiltinthedirectoriesin./examples

TheQttutorialsarebuiltinthedirectoriesin./tutorial

Enjoy!-theTrolltechteam

#makeinstall

可在/usr/local/Trolltech/QtEmbedded-3.3.7-mips/目录查看到编译生成文件。

编译过程可能遇到的问题:

问题1

/usr/bin/ld:skippingincompatible/TSLIB/lib/libts.sowhensearchingfor-lts

/usr/bin/ld:cannotfind-lts

collect2:ld返回1

make[2]:***[../../bin/moc]错误1

出错原因:找不到触摸屏动态库,编译QTmoc工具时出错,但是/TSLIB/lib/libts.so提供的是交叉编译需要的动态库。

解决方法:

#apt-getinstallqt3-dev-toolsqt3-qtconfigqt3-docqt3-designerqt3-assistantqt3-apps-dev

#cp/usr/share/qt3/bin/moc./bin/moc

问题2

make[3]:/home/ethan/Desktop/qtmake/qt-embedded-free-3.3.7-tslib-test/bin/uic:命令未找到

出错原因:找不到编译需要的uic工具

解决方法:

#apt-getinstallqt3-dev-toolsqt3-qtconfigqt3-docqt3-designerqt3-assistantqt3-apps-dev

#cp/usr/share/qt3/bin/uic./bin/uic

其他可能问题的解决方法:

提示找不到头文件、函数未定义或者提示/usr/bin/ld:cannotfind-lxxx,其中xxx即表示函式库文件名称,其命名规则是:lib+库名(xxx)+.so,会发生这样的原因有以下三种情形:

1.系统没有安装相对应的lib

2.相对应的lib版本不对

3.lib(.so)的symboliclink不正确,没有连结到正确的函式库文件(.so)

解决方法:

(1)先判断在/usr/lib下的相对应的函式库文件(.so)symboliclink是否正确,若不正确改成正确的连结目标即可解决问题。

(2)若不是symboliclink的问题引起,而是系统缺少相对应的lib安装lib即可解决。

(3)如何安装缺少的lib:先搜寻相对应的LIB再进行安装

#apt-cachesearchlibxxx-dev

#apt-getinstalllibxxx-dev

若搜索到相关项,执行安装即可,若搜索不到,可上网搜索相关内容,此种错误一般很容易在网上找到解决方法。

4.QT程序移植及运行环境配置

下边将以QT自带example为例讲述移植过程:

在编译之前,需要先制定好编译的QT环境变量,为了方便使用,建议使用脚本进行配置,在程序源文件目录中新建一个qte3-path.sh的文件,内容如下:

File:./qte3-path.sh

exportQTDIR=/usr/local/Trolltech/QtEmbedded-3.3.7-mips/

exportQTEDIR=$QTDIR

exportLD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

exportLD_LIBRARY_PATH=/TSLIB/lib:$LD_LIBRARY_PATH

exportPATH=/home/cpu/gcc-3.4.6-2f/bin:$PATH

然后执行以下命令:

#chmoda+xqte3-path.sh

#sourceqte3-path.sh

#cdqt-embedded-free-3.3.7-tslib-test/examples/widgets

#$QTDIR/bin/qmake

#make

编译成功后可在目录下找到生成的二进制可执行文件widgets,查看该二进制可执行文件相关链接库信息:

#mipsel-linux-readelf-dwidgets

Dynamicsectionatoffset0x15ccontains33entries:

标记类型名称/

0x00000001(NEEDED)共享库:[libts-1.0.so.0]

0x00000001(NEEDED)共享库:[libqte-mt.so.3]

0x00000001(NEEDED)共享库:[libdl.so.2]

0x00000001(NEEDED)共享库:[libpthread.so.0]

0x00000001(NEEDED)共享库:[libstdc++.so.6]

0x00000001(NEEDED)共享库:[libm.so.6]

0x00000001(NEEDED)共享库:[libgcc_s.so.1]

0x00000001(NEEDED)共享库:[libc.so.6]

0x0000000f(RPATH)Libraryrpath: [/usr/local/Trolltech/QtEmbedded-3.3.7-mips/lib]

可以看到Libraryrpath即链接库目录为:

/usr/local/Trolltech/QtEmbedded-3.3.7-mips/lib

还有根据之前安装交叉编译工具链所带的基本库目录为:

/home/cpu/gcc-3.4.6-2f/mipsel-linux/lib/

我们可以在这两个目录下将运行widgets所需要的链接库文件都拷贝出来:

eg.

#cp/usr/local/Trolltech/QtEmbedded-3.3.7-mips/lib/libqte-mt.so.3.

这些*.so文件即为在Loongson1B开发板上运行QT程序widgets所需要的动态链接库文件。

接下来需要说明一下板上文件系统内QT环境参数设置问题:

上边可以看到QTLibraryrpath的路径参数为:

/usr/local/Trolltech/QtEmbedded-3.3.7-mips/lib

在开发板上,默认的QT路径即为:

/usr/local/Trolltech/QtEmbedded-3.3.7-mips/

故而我们只需要将运行QT程序需要的相关库文件及相关文件放置在此目录下,板上系统在运行QT程序时即会自动搜索此目录下的相应文件进行加载,该目录下的目录结构一般如下:

/usr/local/Trolltech/QtEmbedded-3.3.7-mips/-->

{

lib/ --> fonts

plugins --> imageformats

translations

}

lib目录用于放置运行QT程序需要的动态库文件,lib目录内的fonts用于放置QT程序需要的字体文件;

plugins用于放置运行QT程序需要加载的插件,一般情况下显示图片需要用到imageformats插件;

translations用于放置QT程序语言国际化支持的翻译文件。

而构建自己的QT文件夹,相关文件需要按照以上QT文件目录结构进行放置,需要注意的是,无论是否需要加载字体,fonts文件夹内必须存在一个名为fontdir的文件,否则运行会报错,其作用是用来辅助配置解析当前目录下的字体文件。

同时为了TSLIB触摸屏支持,我们需要将之前编译完成的TSLIB文件夹拷贝到板上的文件系统,默认存放位置为编译QT时指定的TSLIB路径。

当然我们也可以通过配置环境变量参数来改变QT目录及TSLIB目录的路径,下边列出板上设置的环境参数设置:

File:/etc/profile

...

#指定QT目录,可更改成自己的QT目录路径

exportQTDIR=/usr/local/Trolltech/QtEmbedded-3.3.7-mips

#指定中文编码格式,解决中文乱码问题,当然程序中也必须为UTF-8格式编码

exportLC_ALL=zh_CN.UTF-8

exportLANG_ALL=zh_CN.UTF-8

exportLANG=zh_CN.UTF-8

#指定TSLIB目录,可更改成自己的TSLIB目录路径

exportTSLIB_ROOT=/TSLIB

#指定相关TSLIB运行参数及设备类型

exportTSLIB_CONSOLEDEVICE=none

exportTSLIB_FBDEVICE=/dev/fb0

exportTSLIB_TSDEVICE=/dev/event0

exportTSLIB_CALIBFILE=/etc/pointercal

exportTSLIB_CONFFILE=/TSLIB/etc/ts.conf

exportTSLIB_PLUGINDIR=/TSLIB/lib/ts

exportTSLIB_TSEVENTTYPE=INPUT

#指定QT支持TSLIB触摸屏设备

exportQWS_MOUSE_PROTO=Tslib:/dev/event0

#指定QT库及TSLIB库加载路径

exportLD_LIBRARY_PATH=$QTDIR/lib:$TSLIB_ROOT/lib:/usr/local/lib:$LD_LIBRARY_PATH

#设置QT程序显示参数

exportQWS_DISPLAY="LinuxFb:mmWidth100:mmHeight130:0"

#指定QT程序加载字体路径

exportQT_QWS_FONTDIR=$QTDIR/lib/fonts

#指定QT程序加载插件路径

exportQT_PLUGIN_PATH=$QTDIR/plugins/

...

进行以上配置之后,即可在板子上运行程序,第一次使用TSLIB触摸屏,需要对触摸屏进行校准:

#$TSLIB_ROOT/bin/ts_calibrate

校准后在/etc目录下会生成一个名为pointercal的校准配置文件

#./widgets-qws

这里需要说明的是:qws的全称是Qtwindowssystem,是QT自行开发的窗口系统,体系结构类似XWindows,是一个C/S结构,由QWSServer在物理设备上显示,由QWSClient实现界面,两者通过socket进行彼此的通讯,而这里后边加的运行参数-qws是指明程序是QWSServer

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值