嵌入式QT开发环境搭建

来源:互联网 发布:ubuntu挂载光盘 编辑:程序博客网 时间:2024/05/15 17:25

我的系统版本信息(RHEL6.0):
[root@LenovoZ460ofWZW Trolltech]# uname -a
Linux LenovoZ460ofWZW 2.6.32-71.el6.i686 #1 SMP Wed Sep 1 01:26:34 EDT 2010 i686 i686 i386 GNU/Linux

RHEL6.0自身是带QT4.6.2的,在装系统时可以选择安装,但是没有qvfb工具,所以又自己重新编译了qt-x11的4.5.0版本。

qt各版本版本下载地址(在网上找的很多博文里给的链接都失效了,下面这个链接貌似还比较新,现在可以用):
http://qt-project.org/downloads
ftp://ftp.qt-project.org/qt/source/
在ftp资源里找到 qt-x11-opensource-src-4.5.0、qt-embedded-linux-opensource-src-4.5.0这两个源码包并下载(tar.gz或tar.bz2包都有,网速不好的话看哪个小下载哪个)。

下载后将两个源码包分别解压,qt-x11-opensource-src-4.5.0解压一份,qt-embedded-linux-opensource-src-4.5.0解压两份,分别命名为qt-embedded-linux-opensource-src-4.5.0-x86 和 qt-embedded-linux-opensource-src-4.5.0-arm 。

开始编译安装:

一、X11编译:
    1.进入qt-x11-opensource-src-4.5.0源码目录。
    
     ./configure -no-openssl         
    在我这里必须加上-no-openssl选项,否则在make过程中,编译到ssl时会报错。出错信息为:
    ssl/qsslsocket_openssl_symbols_p.h:264: error: variable or field ‘q_sk_free’ declared void
    ssl/qsslsocket_openssl_symbols_p.h:264: error: ‘STACK’ was not declared in this scope
    ssl/qsslsocket_openssl_symbols_p.h:264: error: ‘a’ was not declared in this scope
    ssl/qsslsocket_openssl_symbols_p.h:265: error: ‘STACK’ was not declared in this scope
    ssl/qsslsocket_openssl_symbols_p.h:265: error: ‘a’ was not declared in this scope
    ……
    ……

    默认安装路径为 /usr/local/Trolltech/Qt-4.5.0。可用--prefix 指定其他安装路径。

    2.  gmake                 # linux下一般可直接用make代替gmake。如果要加快编译速度,就加上  -jx ,x表示最大的线程数。

    3.  gmake install



二、qt-embedded-x86编译:
    
    1.进入qt-embedded-linux-opensource-src-4.5.0-x86源码目录。
    ./configure -prefix /usr/local/Trolltech/QtEmbedded-4.5.0-x86 -embedded x86 -no-openssl -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb
    先后配置了安装目录、嵌入式架构(x86)。同时也跟X11版本一样,配置了 -no-openssl,没有这一项的话,make的过程中会出现跟编译X11时一样的错误。再后面的几项是为了更好的配合qvfb,网上说如果没有这几项,安装好qt-embedded-x86后想在qvfb上调试程序时,会出现类似下面的错误:    
    Error opening buffer device /dev/fb0QScreenLinuxFb::connect: No such file or directory
 
    2. gmake    
    跟x11版一样
    3. gamke install

三、qt-embedded-arm:
    与前面两个不同,在编译arm版本的qt-embedded前,必须确认已经安装了交叉工具链,编译过程中要生成许多arm架构的库,所以必须有arm-linux-gcc、arm-linux-g++等工具。我用的是友善提供的arm-linux-gcc-4.5.1版本。
    1. 进入qt-embedded-linux-opensource-src-4.5.0-arm源码目录。
    ./configure -prefix /usr/local/Trolltech/QtEmbedded-4.5.0-arm -embedded arm -no-openssl -qt-libpng
    指定了安装路径、嵌入式架构。同时也跟X11版本一样,配置了 -no-openssl,没有这一项的话,make的过程中会出现跟编译X11时一样的错误。
    另外,还增加了一项, -qt-libpng,这个选项应该是关于png相关的库,指定用qt自带的png库。如果没有这一项,我这里会出现如下错误:
    image/qpnghandler.cpp: In member function 'virtual QVariant QPngHandler::option(QImageIOHandler::ImageOption) const':
    image/qpnghandler.cpp:950:35: warning: 'png_info_struct::width' is deprecated (declared at /opt/FriendlyARM/toolschain/4.5.1/lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/include/png.h:639)
    image/qpnghandler.cpp:950:35: warning: 'png_info_struct::width' is deprecated (declared at /opt/FriendlyARM/toolschain/4.5.1/lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/include/png.h:639)
    image/qpnghandler.cpp:950:55: warning: 'png_info_struct::height' is deprecated (declared at /opt/FriendlyARM/toolschain/4.5.1/lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/include/png.h:640)
    image/qpnghandler.cpp:950:55: warning: 'png_info_struct::height' is deprecated (declared at /opt/FriendlyARM/toolschain/4.5.1/lib/gcc/arm-none-linux-gnueabi/4.5.1/../../../../arm-none-linux-gnueabi/include/png.h:640)
    make[1]: *** [.obj/release-shared-emb-arm/qpnghandler.o] 错误 1
    make[1]: *** 正在等待未完成的任务....
    make[1]: Leaving directory `/root/qt4.5.0/qt-embedded-linux-opensource-src-4.5.0-arm/src/gui'
    make: *** [sub-gui-make_default-ordered] 错误 2
    
    看起来像是我的交叉工具链跟这个QT版本匹配的不太好,Qt好像不太兼容交叉工具链的png.h头文件中定义的数据结构。加上 -qt-libpng 可解决此问题。


四、qvfb:
    这时QT就已安装成功。但是还需要额外安装qvfb。
    进入qt-x11-opensource-src-4.5.0源码包目录,然后
    cd tools/qvfb
    在qvfb源码目录下运行 make 会在qt-x11-opensource-src-4.5.0/bin下生成qvfb,我们将它copy至/usr/local/Trolltech/QtEmbedded-4.5.0-x86/bin下即可。


    
end:    
    到这里,QT的开发环境基本就搭建好了,利用 qt-embedded-x86 和 qvfb 工具可以很方便的调试QT程序,调试好的程序再经 qt-embedded-arm 编译就可在开发板上运行(还有个小问题,我现在编译好的QT程序虽然可以在开发板上运行,但是运行时触摸屏不能用,只能用USB鼠标控制,想支持触摸屏貌似还需要移植tslib库,等我折腾完了再回来把相关内容补充上)。    



    下面这两篇博文可能会有帮助,也是关于QT开发环境搭建的,大同小异,还提到了qvfb的用法等,贴出来供大家参考:

    http://www.360doc.com/content/10/0331/15/971672_21031286.shtml

    http://mobile.51cto.com/symbian-273476.htm


原创粉丝点击