最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

buildroot-2009.11下编译QT (Qtopia) 4.5.2 过程记录

工作和技术 crifan 4854浏览 0评论

关于 QT, QT/E Qtopia等的关系,参见:
[转]Qt Qt/E Qtopia 的关系

下面所说的QT,是嵌入式系统的包含了QT Core和QT GUI组件的Qtopia。

在buildroot中加上对qt的支持

去make menuconfig中选上QT:

Package Selection for the target --->
Graphic libraries and applications (graphic/text) --->
[*] Qt --->

根据自己的需要,配置QT


一般情况下,使用默认配置,即可。

此处,说说我的一些理解:

记得要选上License

[*]   Approve free license


对照对应的config和makefile:

package/qt/Config.in

package/qt/qt.mk


中可以找到具体含义:

ifeq ($(BR2_PACKAGE_QT_LICENSE_APPROVED),y)
QT_CONFIGURE += -opensource -confirm-license
endif

即在QT的./configure 中加上参数:

-opensource -confirm-license

其中:

  • -opensource表示是开源的
  • -confirm-license表示在./configure 后,同意对应的授权

如果不选上此项,要要么自己手动输入“yes”,要么参考别人的做法,在qt.mk中,

加上echo "yes":

PKG_CONFIG_PATH="$(STAGING_DIR)/usr/lib/pkgconfig:$(PKG_CONFIG_PATH)"

echo "yes" |

./configure

这样,才可以接续编译QT。

加上JPEG的支持

此处我自己加上了关于JPEG的支持:JPEG support (System libjpeg)

此处,选用系统自己带的libjpeg,buildroot中就会自动选上jpeg支持并下载源码,编译,将编好的库放到output/target/usr/lib/下面。

其他配置使用默认配置

其他QT选项的,均用默认配置即可,最后配置如下:

--- Qt                                                                     │ │
│ │    [ ]   Compile with debug support                                           │ │
│ │          Library type (Shared library) --->                                  │ │
│ │    [*]   Approve free license                                                 │ │
│ │    [ ]   Compatibility with Qt3                                               │ │
│ │    [*]   Gui Module                                                           │ │
│ │            Pixel depths --->                                                 │ │
│ │    [ ]     Enable GIF support                                                 │ │
│ │    [ ]     Enable libmng support                                              │ │
│ │            JPEG support (System libjpeg) --->                                │ │
│ │            PNG support (No PNG support) --->                                 │ │
│ │            TIFF support (No TIFF support) --->                               │ │
│ │          zlib support (Qt zlib) --->                                         │ │
│ │          freetype2 support (no freetype2 support) --->                       │ │
│ │    (arm) The embedded platform we are making Qt for                           │ │
│ │    [ ]   SQL Module --->                                                     │ │
│ │          Graphics drivers --->                                               │ │
│ │          Mouse drivers --->                                                  │ │
│    [ ]   Phonon Module                                                        │ │
│ │    [*]   XML Module                                                           │ │
│ │    [ ]     XML Patterns Module                                                │ │
│ │    [ ]   SVG Module                                                           │ │
│ │    -*-   Network Module                                                       │ │
│ │    [ ]     WebKit Module                                                      │ │
│ │    [ ]   STL support                                                          │ │
│ │    [ ]   Enable OpenSSL support                                               │ │
│ │    [*]   Script Module                                                        │ │
│ │    [ ]     Script Tools Module                                                │ │

注意是否编译demo程序

此buildroot版本中的QT配置,默认在./configure参数中,加上了

-fast -nomake examples -nomake demos

使得QT没有编译demo程序,因此,在第一次成功编译QT后,去删除了旧的:

rm output/build/qt-embedded-linux-opensource-src-4.5.2/ -rf

然后去修改/package/qt/qt.mk,把其中的

-fast -nomake examples -nomake demos 

改为

-no-fast

使得其去编译所有QT的东西。

这些参数具体含义,自己去

output/build/qt-embedded-linux-opensource-src-4.5.2/

下面,输入:

./configure --help

即可查到。

同时还修改了QT的安装路径,即原先默认参数

 -prefix /usr

我改为了

-prefix $(TARGET_DIR)/usr

让其安装到buildroot中默认的rootfs文件夹下的usr,即output/target/usr下面。

对于buildroot中的QT,只能一次性地配置并编译成功


配置完毕所有的,直接make,buildroot就会去帮你完成对应的配置,生成makfile,编译等一些列的事情了。不过要注意一点的是,在你make完毕之后,去修改QT里面的配置,再make,对QT来说是没用的,因为QT是根据你的配置,去生成对应的makefile,用qmake去编译的。也就是说,在第一次配置QT并make后,之后在重新配置QT,比如再加入某项支持,这些配置都是无效的。

那想要让新的配置生效,那只有全部删除刚编译好的,旧的:

rm output/build/qt-embedded-linux-opensource-src-4.5.2/ -rf

一次性地配置好QT,然后再重新make,buildroot就会从dl/qt-embedded-linux-opensource-src-4.5.2.tar.gz 下面解压,根据你的配置,去./configure ,再生成makefile,再去qmake。

即使中间make出错了,比如我刚才遇到的,在某个examples下面某个文件夹里面,在执行make install的时候,出现不能创建 /usr/example之类的问题(所以,我才想起来去将默认的安装路径,/usr/改为output/target/usr的),然后再make,都无法有效地去再现刚才的错误。

感觉好像是,make不能再去调用到QT的Qmake了,所以,只能一次性地去QT里面配置好,然后在buildroot中去make完毕,错了都没办法。。。只能重新来过。。。晕死。。希望以后版本可以改进。

不过,好在我这里,按照上面的配置之后,重新make后,是可以正常make编译并install安装到QT的库以及其他相关demos和examples到output/target/usr下面的:

crifan@crifan-laptop:usr$ pwd
/home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/target/usr

crifan@crifan-laptop:usr$ ls lib/*Qt* -l
lrwxrwxrwx 1 crifan crifan      18 2010-04-10 14:02 lib/libQtCore.so.4 -> libQtCore.so.4.5.2
lrwxrwxrwx 1 crifan crifan      18 2010-04-10 14:02 lib/libQtCore.so.4.5 -> libQtCore.so.4.5.2
-rwxr-xr-x 1 crifan crifan 2472352 2010-04-10 14:02 lib/libQtCore.so.4.5.2
lrwxrwxrwx 1 crifan crifan      17 2010-04-10 14:02 lib/libQtGui.so.4 -> libQtGui.so.4.5.2
lrwxrwxrwx 1 crifan crifan      17 2010-04-10 14:02 lib/libQtGui.so.4.5 -> libQtGui.so.4.5.2
-rwxr-xr-x 1 crifan crifan 7592876 2010-04-10 14:02 lib/libQtGui.so.4.5.2
lrwxrwxrwx 1 crifan crifan      21 2010-04-10 14:02 lib/libQtNetwork.so.4 -> libQtNetwork.so.4.5.2
lrwxrwxrwx 1 crifan crifan      21 2010-04-10 14:02 lib/libQtNetwork.so.4.5 -> libQtNetwork.so.4.5.2
-rwxr-xr-x 1 crifan crifan 659820 2010-04-10 14:02 lib/libQtNetwork.so.4.5.2
lrwxrwxrwx 1 crifan crifan      20 2010-04-10 14:02 lib/libQtScript.so.4 -> libQtScript.so.4.5.2
lrwxrwxrwx 1 crifan crifan      20 2010-04-10 14:02 lib/libQtScript.so.4.5 -> libQtScript.so.4.5.2
-rwxr-xr-x 1 crifan crifan 855952 2010-04-10 14:02 lib/libQtScript.so.4.5.2
lrwxrwxrwx 1 crifan crifan      17 2010-04-10 14:02 lib/libQtXml.so.4 -> libQtXml.so.4.5.2
lrwxrwxrwx 1 crifan crifan      17 2010-04-10 14:02 lib/libQtXml.so.4.5 -> libQtXml.so.4.5.2
-rwxr-xr-x 1 crifan crifan 223984 2010-04-10 14:02 lib/libQtXml.so.4.5.2

crifan@crifan-laptop:usr$ ls demos/ -l
总用量 68
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 affine
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 books
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 chip
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 composition
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 deform
-rw-r--r-- 1 crifan crifan 2064 2010-04-10 15:19 demos.pro
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 embedded
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 embeddeddialogs
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 gradients
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 interview
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 mainwindow
drwxr-xr-x 2 crifan crifan 4096 2010-04-10 15:20 pathstroke
-rw-r--r-- 1 crifan crifan 1349 2009-06-20 13:02 README
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 shared
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 spreadsheet
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 textedit
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 undo

crifan@crifan-laptop:usr$ ls examples/ -l
总用量 96
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:19 desktop
drwxr-xr-x 10 crifan crifan 4096 2010-04-10 15:19 dialogs
drwxr-xr-x 7 crifan crifan 4096 2010-04-10 15:19 draganddrop
-rw-r--r-- 1 crifan crifan 1279 2009-06-20 13:02 examples.pro
drwxr-xr-x 8 crifan crifan 4096 2010-04-10 15:19 graphicsview
drwxr-xr-x 5 crifan crifan 4096 2010-04-10 15:19 ipc
drwxr-xr-x 18 crifan crifan 4096 2010-04-10 15:19 itemviews
drwxr-xr-x 6 crifan crifan 4096 2010-04-10 15:19 layouts
drwxr-xr-x 5 crifan crifan 4096 2010-04-10 15:19 linguist
drwxr-xr-x 8 crifan crifan 4096 2010-04-10 15:19 mainwindows
drwxr-xr-x 16 crifan crifan 4096 2010-04-10 15:19 network
drwxr-xr-x 8 crifan crifan 4096 2010-04-10 15:19 painting
drwxr-xr-x 7 crifan crifan 4096 2010-04-10 15:19 qtconcurrent
drwxr-xr-x 5 crifan crifan 4096 2010-04-10 15:20 qws
-rw-r--r-- 1 crifan crifan 1420 2009-06-20 13:02 README
drwxr-xr-x 5 crifan crifan 4096 2010-04-10 15:19 richtext
drwxr-xr-x 8 crifan crifan 4096 2010-04-10 15:20 script
drwxr-xr-x 9 crifan crifan 4096 2010-04-10 15:19 sql
drwxr-xr-x 5 crifan crifan 4096 2010-04-10 15:19 threads
drwxr-xr-x 14 crifan crifan 4096 2010-04-10 15:19 tools
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 tutorials
drwxr-xr-x 3 crifan crifan 4096 2010-04-10 15:20 uitools
drwxr-xr-x 25 crifan crifan 4096 2010-04-10 15:20 widgets
drwxr-xr-x 7 crifan crifan 4096 2010-04-10 15:20 xml

不过,至于能否在板子上面跑起来QT,那就要只有再去测试了。

qtdemo的故事


[下面所说的路径,非特殊说明,当前目录以output/build/qt-embedded-linux-opensource-src-4.5.2为准。]

因为编译完成后,想要找个demo程序,因此,就发现了qtdemo。

在看了INSTALL:

To create the library and compile all the demos, examples, tools,

and tutorials, type:

make

和README:

DEMOS AND EXAMPLES

Once Qt is installed, we suggest that you take a look at the demos and

examples to see Qt in action. Run the Qt Examples and Demos either by

typing ‘qtdemo’ on the command line or through the desktop’s Start

menu.

以及demos/README:

On Unix/Linux:

The qtdemo executable is installed alongside the other Qt tools on the path

specified when Qt is configured

后,在确保buildroot中加入对应的demos的编译参数后

(即,加上了-no-fast,就应该去编译所有的部分,包括examples和demos,而且也可以去查看./config.status查看实际的配置,我的此处是:

#!/bin/sh
if [ "$#" -gt 0 ]; then
/home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/build/qt-embedded-linux-opensource-src-4.5.2/configure -silent -force-pkg-config -embedded arm -prefix /home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/target/usr -no-fast -opensource -confirm-license -largefile -no-qt3support -depths 1,4,8,16,32 -qt-gfx-linuxfb -no-gfx-transformed -no-gfx-qvfb -no-gfx-vnc -no-gfx-multiscreen -no-mouse-pc -no-mouse-bus -no-mouse-linuxtp -no-mouse-yopy -no-mouse-vr41xx -no-mouse-tslib -no-mouse-qvfb -release -shared -little-endian -no-gif -no-libmng -qt-zlib -system-libjpeg -no-libpng -no-libtiff -no-freetype -no-openssl -no-sql-sqlite -no-xmlpatterns -no-phonon -no-svg -no-webkit -no-stl -no-xinerama -no-cups -no-nis -no-accessibility -no-separate-debug-info -hostprefix /home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/staging/usr -no-rpath "$@"
else
/home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/build/qt-embedded-linux-opensource-src-4.5.2/configure -silent -force-pkg-config -embedded arm -prefix /home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/target/usr -no-fast -opensource -confirm-license -largefile -no-qt3support -depths 1,4,8,16,32 -qt-gfx-linuxfb -no-gfx-transformed -no-gfx-qvfb -no-gfx-vnc -no-gfx-multiscreen -no-mouse-pc -no-mouse-bus -no-mouse-linuxtp -no-mouse-yopy -no-mouse-vr41xx -no-mouse-tslib -no-mouse-qvfb -release -shared -little-endian -no-gif -no-libmng -qt-zlib -system-libjpeg -no-libpng -no-libtiff -no-freetype -no-openssl -no-sql-sqlite -no-xmlpatterns -no-phonon -no-svg -no-webkit -no-stl -no-xinerama -no-cups -no-nis -no-accessibility -no-separate-debug-info -hostprefix /home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/staging/usr -no-rpath
fi

然后再make,按理来说,就会自动make编译并install安装QT到我所指定的output/target/usr下面,那下面,应该也就能找到前面介绍的qtdemo程序才对。

但是实际是,去output/target/usr/下面,没有找到qtdemo,倒是找到了已经正常安装过来的 demos和examples.

而qtdemo,去看了下qt源码,是在demos/qtdemo下面的,但是demos下面的其他的程序,比如mainwindow,都正常编译并安装过来了,为何qtdemo没有安装过来?很是纳闷.

经过一番地查看源码,makefile,配置文件,最后终于搞懂,前面那些README中说的qtdemo和这里为何没有安装qtdemo了。

此qtdemo非彼qtdemo:


首先,前面README中说的qtdemo,并不是此处的qtdemo,因为, demos/README中说到的qtdemo是对于 “On Unix/Linux",是普通PC上的Linux中安装的qtdemo。

而我们这里的qtdemo,是针对于Embedded Linux的,并不是PC上Linux/Unix,

关于这些平台之间的支持和差别,参见:

http://qt.nokia.com/products/platform

其中支持很多平台,包括:

Embedded Linux,Mac,Linux/X11,Windows,Symbian等。

这里的Embedded Linux和Linux,是两个不同的平台。

对于QT使用到的图形输出,Linux用的是X11,Embedded Linux用的一般是Framebuffer。

QT中QWS的意思


正是上面的帖子,提到了之前很困惑的,啥是QWS了,因为,之前自己曾尝试手动单独去编译QTopia,在./configure的时候,在指定交叉编译平台,-xplatform后面加上target的时候,参考别人,用了linux-arm-g++结果死活说是在mkspecs下面找不到这个,不支持,而后来发现,将其换成是另一个人用的mkspecs/qws/linux-arm-g++,就可以了。但是对于qws,之前不清楚,到底啥意思。这上面的帖子中,解释的很清楚了:

http://qt.nokia.com/products/platform/qt-for-embedded-linu

Compact & Efficient Windowing System (QWS)

Qt builds on the standard API for embedded Linux devices with its own compact window system. Qt-based applications write directly to the Linux framebuffer, eliminating the need for the X11 windowing system.

  • Reduced memory consumption and smaller footprint
  • Highly optimized software rendering, utilizing processor SIMD* units
  • Unused components and features can be compiled out

简单说就是专门面向于嵌入式系统,精简了的Linux,使用Framebuffer作为输出,优点就是资源占用更少,作了优化,更多地使用单指令多数据类型指令以提高代码效率,去掉普通Linux中用不到的那些组件。

为何此处的qtdemo没有被编译并安装


搞清楚了,上面说的qtdemo是两个不同平台下面的之后,还有个疑问就是,为何此处,Embedded linux

下的demos/下面的qtdemo,为何没有被编译并安装到output/target/usr下面?

在追踪了一对的配置文件,makefile等之后,终于看懂了过程:

首先,qt的根目录下面的makefile中,是加入了对应的demos的:

./makefile:
SUBTARGETS    =
。。。
sub-examples
sub-demos
,然后进入到demos中,其makefile中,找不到对应的qtdemo,而其他比如mainwindow之类的,都是有的:
demos/Makefile:
SUBTARGETS    =
sub-shared
sub-deform
sub-gradients
sub-pathstroke
sub-affine
sub-composition
sub-books
sub-interview
sub-mainwindow
sub-spreadsheet
sub-textedit
sub-chip
sub-embeddeddialogs
sub-undo
sub-embedded

然后,发现demos/Makefile中最上面,写的:

demos/Makefile:

#############################################################################
# Makefile for building: demos
# Generated by qmake (2.01a) (Qt 4.5.2) on: ?? 4? 10 15:20:04 2010
# Project: demos.pro
# Template: subdirs
# Command: /home/crifan/develop/buildroot/as353x/buildroot-2009.11/output/build/qt-embedded-linux-opensource-src-4.5.2/bin/qmake -spec ../mkspecs/qws/linux-arm-g++ -unix -o Makefile demos.pro
#############################################################################


因此去找到demos/demos.pro,

其最开始,是只配置了基本的模块:

demos/demos.pro:
SUBDIRS     =
demos_shared
demos_deform
demos_gradients
demos_pathstroke
demos_affine
demos_composition
demos_books
demos_interview
demos_mainwindow
demos_spreadsheet
demos_textedit
demos_chip
demos_embeddeddialogs
demos_undo

而后,根据当前的编译配置,决定是否加入qtdemo:

demos/demos.pro:
!cross_compile:{
contains(QT_BUILD_PARTS, tools):{
!wince*:SUBDIRS += demos_sqlbrowser demos_qtdemo
wince*: SUBDIRS += demos_sqlbrowser
}
}

我们这里,是在x86平台下,交叉编译arm平台的qt,所以是cross_compile,因此不会执行这部分:

demos/demos.pro:
contains(QT_BUILD_PARTS, tools):{
!wince*:SUBDIRS += demos_sqlbrowser demos_qtdemo
wince*: SUBDIRS += demos_sqlbrowser
}

因此,就没有加入qtdemo和sqlbrowser。

而且,对于是cross_compile来说,就不加入tools模块的编译,是在qt根目录的configure中就有判断的:

./configure :
#setup the build parts
if [ -z "$CFG_BUILD_PARTS" ]; then
CFG_BUILD_PARTS="$QT_DEFAULT_BUILD_PARTS"

# don't build tools by default when cross-compiling
if [ "$PLATFORM" != "$XPLATFORM" ]; then
CFG_BUILD_PARTS=`echo "$CFG_BUILD_PARTS" | sed "s, tools,,g"`
fi
fi

因此,最后的结果就是,由于是交叉编译,所以没有编译qtdemo,因此也就无法去install到output/target/usr下的demos下面了。

不过,对应地,demos和examples下面,还有有很多编译并安装好的测试组件用于demo的。

转载请注明:在路上 » buildroot-2009.11下编译QT (Qtopia) 4.5.2 过程记录

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (3)

  1. 回复againinput4:哦。刚认识到只有2.2之前的才有桌面系统。。。
    xxj05014年前 (2010-08-29)回复
  2. 回复xxj050:buildroot下编译Qtopoia,本来就是面向嵌入式环境的,所以没有PC版的桌面系统,是正常的啊。
    againinput414年前 (2010-08-27)回复
  3. 你好,我刚移植了qtopia4.7,可以正常运行例子中的程序,但是在哪里有qt的桌面系统呢?貌似编译出来的可执行文件没有桌面系统的啊?
    谢谢~~
    xxj05014年前 (2010-08-26)回复
83 queries in 0.186 seconds, using 22.21MB memory