最近公司做一个linux手机项目,需要做一个图形界面程序,移植qtopia,其中遇到一些难题也折腾了1个多星期,总算是弄好了,这里总结一下。分为以下几部分:
1 编译运行x86版本的qtopia
2 编译移植mips处理的qtopia
3 在qtopia4.4.3下编译运行helloworld程序
4 编译运行中遇到的问题和解决方法
5 qtopia的qconfigure选项详解
6 qtopia的裁剪
qtopia4的X86版和mips版我分别解压到不同目录分别更名命*-src和*-src-mips
一 编译运行X86版本的qtopia
(1)准备源码:
qt-extended-opensource-src-4.4.3.tar.gz
tslib-1.4.1.tar.bz2
Ubuntu—linux-2.6.25
mipsel-linux-gcc-4.3.0.tgz
1.)解压源码qt-extended-opensource-src-4.4.3.tar.gz到qtopia4目录中
2)创建目录build 和target
[root@abilly qtopia4]# ls
build target
qt-extended-4.4.3-src
3)设置环境变量
export QPEDIR=/home/work/qtopia/build
export QTOPIA_DEPOT_PATH =/home/work/qtopia/qt-extended-4.4.3-src
4)配置与编译,安装与运行
配置前可以到qt-extended-4.4.3下运行/configure –help看看选项说明
./configure --help
。。。。。。。
然后配置如下:进入build目录
../qt-extended-4.4.3-src/configure -build-qt -image /home/work/qtopia/target -prefix /home/work/qtopia/target
after long long time。。。。。
bin/qbuild.
If you run bin/qbuild image, this will setup a runnable image in
/home/work/qtopia/target.
As configured, Qt Extended MUST be run from /home/abilly/qtopia4/target. If
this is not where you intend to run Qt Extended from you should set the
location by running configure -prefix /opt/Qtopia.
You have new mail in /var/spool/mail/root
配置成功
编译:
bin/qbuild
……
Qt Extended has been built.
You must now install Qt Extended by running 'bin/qbuild image'.
This will put the files required to run Qt Extended into the image:
/home/work/qtopia/target
Before you can use the SDK you must finalize it by running 'bin/qbuild sdk'.
This will put the required files into the SDK:
/home/work/qtopia/build/sdk
安装:
bin/qbuild image
。。。。
Qt Extended has been installed.
The files required to run Qt Extended are in the image:
/home/work/qtopia/target
Please note that Qt Extended cannot be moved. It must be run from the image.
编译开发包
bin/qbuild sdk
(10多分钟即可)
Finalizing the SDK
/home/work/qtopia/qt-extended-4.4.3-src/src/build/bin/sdkcache /home/work/qtopia/build/sdk
WARNING: Your perl has a bug with output and UTF-8
WARNING: sdkcache will attempt to work around the bug by changing your
LANG variable from zh_CN.UTF-8 to zh_CN.
The SDK has been finalized.
It can now be deployed to another computer.
Note that you should run configure before building again.
运行:
[root@abilly build]# bin/runqtopia
二 编译移植mips处理器的qtopia
编译了x86版本的qtopia看了一下效果,下面就要移植qtopia到开发板了,关键的其实就是用交叉编译器进行编译。
要说明的一点是交叉编译器的选择,这点非常重要。
首先是编译器的版本问题,我用4.3版本的编译器,编译过程中会出现一些诡异的链接库问题,怎么也解决不了,然后还用3.4.6的编译器就没有问题。但是运行不显示字体,最后解决这个问题还是用4.3版本的编译器,也采用了一些小手段,才算是终于移植成功,后面会说。
其次就是浮点的问题,可能用3.4.6版本的编译器都能编过去,但是我发现运行起来特别的慢,后来发现我们的处理器没有浮点协处理器,编译器也没有用软浮点,因此内核只能用浮点处理模块(处理异常的方式)来处理浮点运算,效率非常低,用了软浮点的编译器,运算速度提升了一个数量级!对于浮点的问题我还写了一篇文章总结了一下。
1 解压原码包到目录qtopia_mips下,原码包的名字改为qt-extended-4.4.3-src-mips,在创建2个目录,build_mips target_mips。
2 修改环境变量,添加如下2个环境变量:
export QPEDIR=/home/work/qtopia_mips/build_mips
export QTOPIA_DEPOT_PATH=/home/work/qtopia_mips/qt-extended-4.4.3-src-mips
3 编译tslib库,这个库是用来触摸屏校验和防抖的。
解压tslib.1.4.1.tar.gz到目录tslib下
进入原码目录,执行./autogen.sh 生成configure
执行./configure --host=mipsel-linux --prefix=/home/work/mips_tslib 生成Makefile。打开makefile看一下编译工具如CC AR是否变成了mipsel-linux-
执行make
执行make install 会在mips_tslib下生成4个目录 bin etc include lib。
4 进入buil