您的位置:首页 > 编程语言 > Qt开发

编译和移植qt-embedded-linux-opensource-src-4.5.3

2010-08-01 01:39 561 查看
最初的动机是不想使用qtopia来开发qt界面,在网上搜索到qt/embedded也是可以解决的。在网上搜索了好多关于这方面的内容,我找了一个亲身实践的来讲吧。

开发平台:Ubuntu 9.10

目标平台:hfrk s3c2410

交叉工具:arm-linux 版本4.1.2

qt版本:qt-embedded-linux-opensource-src-4.5.3

下载地址:ftp://ftp.qt.nokia.com/qt/source/qt-embedded-linux-opensource-src-4.5.3.tar.gz

我上网找的很多资料中源码包都是过期的下载地址,我这个肯定可以用。

一、检查内核是否有LCD驱动和FrameBuffer

cd /source/kernel/linux-2.6.8

make menuconfig
在界面中找到Graphics support
进入查看Support for framebuffer devices 和 S3C2410 LCD framebuffer support两个选项是否被选中,选中代表内核已支持。

二、解压源码包执行configure

tar zxvf qt-embedded-linux-opsource-src-4.5.3.tar.gz

cd qt-embedded-linux-opsource-src-4.5.3

./configure -prefix /home/lhembed/qt-arm/build/ 这个地址是安装在PC上的目标地址
-release -shared /
-fast /
-pch /
-no-qt3support /
-qt-sql-sqlite /
-no-libtiff -no-libmng /
-qt-libjpeg /
-qt-zlib /
-qt-libpng /
-qt-freetype /
-no-openssl /
-nomake examples -nomake demos -nomake tools /
-optimized-qmake /
-no-phonon /
-no-nis /
-no-opengl /
-no-cups /
-no-xcursor -no-xfixes -no-xrandr -no-xrender -no-xkb -no-sm /
-no-xinerama -no-xshape /
-no-separate-debug-info /
-xplatform qws/linux-arm-g++ /
-embedded arm /
-depths 16 /
-no-qvfb /
-qt-gfx-linuxfb /
-no-gfx-qvfb -no-kbd-qvfb -no-mouse-qvfb /
-qt-kbd-usb /
-confirm-license /
-no-armfpa

以上配置根据个人的需要增减,这里没有支持触屏库,这个以后补充。

make && make install

这里贴出我make的时候出现的错误以及解决方法。

这个时候在指定的安装目录会出现如下目录:bin include lib mkspecs plugins translations

三. 将开发机下的linux-2.6.8文件系统用nfs挂载到开发板上(开发板上/var目录下为可写),

mount –t nfs –o nolock 192.168.1.100:/source/rootfs /var/mnt

然后将上一步生成的lib库文件考到挂载的根文件系统的/home/qt/build/lib目录下

(把交叉编译生成的库文件复制到开发板上的lib文件夹内)

cp /home/lhembed/qt-arm/build/lib/libQt* /source/rootfs/home/qt/build/lib

四.拷贝显示中文的文泉驿字体到根文件系统的相应目录下:

cp /home/lhembed/qt-arm/build/lib/fonts/wenquanyi_160_75.qpf /

/source/rootfs/home/qt/build/fonts

五. 用qt编一个helloworld 程序进行测试。使用qmake、make对程序进行编译。

注意:一定要用qtembed安装目录下bin/下面的qmake

/home/lhembed/qt-arm/build/bin/qmake –project

/home/lhembed/qt-arm/build/bin/qmake

make

六.将上一步生成的可执行文件helloworld考到挂载的根文件系统下

在开发板上设置环境变量

export QTDIR=/var/mnt /home/qt/build

export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

export PATH=$QTDIR/bin:$PATH

export QT_QWS_FONTDIR=/var/mnt /home/qt/build/fonts (这个一定要指定对,否则会出错)

最后运行helloworld程序

./helloworld -qws

我这遇到

error while loading shared libraries: libts-1.0.so.0: cannot open shared object file: No such file or directory

这是开发板原配文件系统问题,我就从交叉编译器中找,发现有上面的库文件。

然后把该库文件(注意libts-1.0.so.0是链接,需要找到对应的库文件)复制到开发板的/lib目录,并模仿建立软连接。

就可以看到界面了。

下面是我自己环境下make时候出现的错误:



上面那个错误导致的原因是库文件没有找到。

http://www.qtforum.org/article/27370/qtembedded-4-5-0-compile-make-error.html

根据上面链接的内容,可以解决问题。

还会出现一个问题:

../../corelib/tools/qlocale.cpp: In function ‘char* qdtoa(double, int, int, int*, int*, char**, char**)’:
../../corelib/tools/qlocale.cpp:6548: error: ‘fenv_t’ was not declared in this scope
../../corelib/tools/qlocale.cpp:6548: error: expected ‘;’ before ‘envp’
../../corelib/tools/qlocale.cpp:6549: error: ‘envp’ was not declared in this scope
../../corelib/tools/qlocale.cpp:6549: error: ‘feholdexcept’ was not declared in this scope
../../corelib/tools/qlocale.cpp:6564: error: ‘fesetenv’ was not declared in this scope
make[1]: *** [.obj/release-static-emb-arm/qlocale.o] 错误 1
make[1]:正在离开目录 `/home/lhembed/qt-embedded/qt-embedded-linux-opensource-src-4.5.3/src/tools/bootstrap'
make: *** [sub-tools-bootstrap-make_default-ordered] 错误 2

网上有部分说法是编译器的版本问题,后来我把/USR/INCLUDE下的FENV.H 拷贝到qlocale.cpp同目录
然后修改qlocale.cpp的#include <fenv.h>成#include "fenv.h"

以上两个问题解决后就经过漫长的make过程一帆风顺。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: