Applied Mechanics and Materials Submitted: 2014-11-12 ISSN: 1662-7482, Vol. 740, pp 782-785 Accepted: 2014-12-02 doi:10.4028/www.scientific.net/amm.740.782 Online: 2015-03-09 2015 Trans Tech Publications, Switzerland Customizing dynamic libraries of Qt based on the embedded Linux Li Yang 1,a, Wang Yunliang 2,b 1 School of Electrical Engineering of TIANJIN UNIVERSITY OF TECHNOLOGY, China 2 Tianjin Key Laboratory for Control Theory & Application in Complicated System, Tianjin University of Technology, China a yanglijuden@foxmail.com b wangyl@tjut.edu.cn Keywords: Embedded Linux, Qt, Customize, transplant Abstract. With the development of embedded system, embedded graphics user friendly, intuitive interface(gui) used for communication with users becomes a research subject. The article mainly introduces the customization of dynamic libraries of Qt under the ARM11 and Linux environment, which can save disk space of the ARM board. 0 Introduction Nowadays, embedded development has attracted more and more developers, the embedded products available in the market also have sprung up. People also constantly improve to the requirement of embedded products, convenient and quick graphical man-machine interface has become an important indicator of products. Linux core due to its open source, robust and stable and can be clipped is widely used in the embedded development. Qt is a support multi-platform c + + graphical interface development tools, because of its characteristics such as object-oriented, cross-platform, rich API was used in the embedded development [1]. Qt is Trolltech Company developed a multi-platform c++ graphical user interface application framework. Including rich API interfaces and c++ class library, used for GUI development and international integration tool. QT/Embedded is specifically for Embedded Linux development tools, it is much more complex than the PC, the installation, operation environment. Most classes of Qt are needless in embedded development, But there classes are compiled into the library, witch lead that the embedded products have to extra pay disk space to the Qt libraries. In order to solve this situation, this paper mainly introduces how to tailor the Qt library. 1 Customize and transplantation of Qt 1.1 Constructing the development environment of Qt Qt has three ways to compile under Linux: qt/x11, Qt/Embedded-x86 and Qt/Embedded- arm. At First installed the qt/x11, generation for embedded development, designer, UI, qvfb, and other tools in the installation directory. Then install the QT/Em-bedded- version of X86, which can simulate the operation of embedded QT application program with PC qvfb frame buffer, so the compiler environment QT/Embedded- x86 and qt/x11 during the installation t is the same, with particular attention to set configuration parameters for this installation, the parameter -embedded x86 specifies the processor platform is x86. In the qt/x11 and QT/Embedded-x86 application program running, to correctly set environment variables, so that the application can correctly calls the installation directory library file. The operation results of QT/Embedded- x86 application show in the qvfb, so before that, cope the qvfb tool which is under the qt/x11 installation directory to the bin directory of QT/Embedded- x86 installation directory. Installing QT/Embedded- x86 is mainly to make developers can debug applications on the PC easily[2][3]. 1.2 Clipping Dynamic library of Qt Due to its rich API, Qt also makes compiled library files much larger than other embedded GUI s development framework. However, it is not possible to use all classes of Qt in the develpment of application. Therefore, clipping on Qt library can save storage space for embedded products, which can be divided into two parts, module clipping and feature clipping. All rights reserved. No part of contents of this paper may be reproduced or transmitted in any form or by any means without the written permission of Trans Tech Publications, www.ttp.net. (ID: 130.203.136.75, Pennsylvania State University, University Park, USA-05/03/16,14:22:20)
Applied Mechanics and Materials Vol. 740 783 From version 4 Qt begins to use a modular form, separating different functions into independent libraries, which makes it simple to remove some unwanted libraries. Qt configure provides some methods of settings module. For example, when passing configure by adding -no-svg or -no-webkit can replace the support of this part. Accordingly, there are many small functions can be configured in the form of configure parameters, referring to the output of configure -help. When checking the configure help, paying special attention to the contents added *, which is the default configure option of Qt. By default, Qt will compile feature as much as possible, which has some advantages that the user can use all the function of Qt, but harm is also very obvious that the Qt compiled by default is large, especially the compilation of the debug version, which take space of 1 to 2 GB basically. In addition, the default condition won't compile some plugins, such as database plugin, which often require the users according to the need to compile. Embedded version of Qt supports feature clipping, we can take advantage of this feature to make Qt libraries as small as possible. Specific approach is to do an own properties file and define the features you want to remove. Firstly run qconfig, the tool compiler-generated by qt / X11 (in the bin directory under the installation directory), then select src/corelib/global/qfeature.txt file under Qt source directory and open it, as shown in Figure 1. Fig. 1 qconfig interface Figure on the left shows the options which can be clipped, standing for modules with different classes or different functions. According to your demand of classes and modules in the development, select these unnecessary classes and modules, and save an arbitrarily named file to the src / corelib / global / directory. Followed by the last configure add -qconfig [file name], compile and install to achieve the crop of Qt feature. In addition, Qt has scheduled a good crop selection, such as qconfigminimal.h, qconfig-small.h, qconfig.medium.h, qconfig-large.h and qconfig-dist.h which can be selected according to the development. The compiled arm version of the library files will be copied to arm development board, and set the Qt environment variables to the system, in this way complete the Qt transplant arm board. 2 Example of simple music player As to the introduction of QT music player, first it s necessary to know about the basic frame of the multimedia, then combining with basic information explain the programming principles of music player [4]. MediaObject manages the media source(start, pause,finish);sink outputs multimedia, usually it s a device of playing, receiving the media information from MediaObject; Path is used for connection between MediaObject and sink. The whole process is as shown in Figure 2. Fig. 2 The whole process
784 Mechanical, Information and Industrial Engineering QT project itself doesn t include the module of Phonon, which needs us to add this module in the project file.pro. In the system of Phonon, MediaObject manages media source(start, pause, finish); AudioOutput connects the physical devices; SeekSlider realizes the progress bar; Qlist realizes the play-list. In the coding they are embodied in the following code. Qlist<Phonon::MediaSource>sourceList;//play-list Then connect the MediaObject and AudioOutput through constructor so that the media data can be transported from MediaObject to AudioOutput; and then play via the physical devices. Phonon::createPath(mediaObject,audioOutput); First we need to add the file of media source through connecting the constructor of interface buttons and adding media files, which needs the signal of Qt and Slots mechanism. connect (addfilesaction, SIGNAL (triggered ( )), this, SLOT(addFiles ())); slot functions of adding media files QStringList files = QFileDialog::getOpenFileNames(this,tr("select files")); QDesktopServices::storageLocation (QDesktopServices::MusicLocation); if(files.isempty()) return; int index= sources.size(); foreach (QStringstring,files)// Browse through each selected files and add them to the play-list { Phonon::MediaSource source(string); sources.append(source); if(!sources.isempty()) metainformationresolver- >setcurrentsource(sources.at(index)); Other signals/slot functions can be realized in the same way connect(pauseaction, SIGNAL(triggered( )), mediaobject, SLOT(pause())); Corresponding control by detecting the current state of the media files void statechanged (Phonon::State newstate,phonon::state /* oldstate */) { switch (newstate){ case Phonon::PlayingState: playaction- >setenabled(false); break; case Phonon::StoppedState: stopaction- >setenabled(false); break; After the application is written, first, set it effective in the PC QT / Embedded- x86 and simulate the result in qvfb; after successful operation, set it effective in QT/Embedded- arm, and then cross-compile the application. Copy the generated executable file to the development board file system and set the environment variables in the above development board effective, and then perform./ executable file name - qws, and then the running effect can be seen in the development board. In this example, the phonon module is used so that it should be joined in the ranks of the compiler when clipping in module clipping.and some Qt classes, including QFileDialog, QTableWidget, QMenuBar, QProgressBar and so on, are also used, which can be clipped and
Applied Mechanics and Materials Vol. 740 785 should be chose in feature clipping.table 1 is the comparison of size between the library of default compilation and the library after clipping based on this example. Table 1. The size of libraries QtCore QtGui default 2.9Mb 8.9Mb tailored 2.1Mb 6.0Mb 3 Conclusion QT/Embedded becomes the mainstream of embedded development as tools of embedded development interface because of its friendly interface and convenient. This article mainly from the building of development environment introduced how to develop applications which run in the ARM board in PC Linux environment, and then illustrates the developed process of a Qt/Embedded application instancing the player. Reference: [1] LEI hong, WU Hui-ting.The Discussion and the Research Based on the Embedded Processors[J]. Information Security and Technology,2011(6):26-28. [2] WANG Hao-nan, Liu Yi-cheng. Development of Qt based on Embedded Linux [J]. Computer Development & Applications, 2010,23(1):12-13. [3] SUN Wei, FENG Wei-xing. Development and Application of Qt /Embedded Applications on ARM-Linux, 2011,30(8):37-38. [4] ZHAO Peng. Design and Implementation of MP3 Player Based on Embedded Linux [J]. Modern Computer,2011(03):110-112.
Mechanical, Information and Industrial Engineering 10.4028/www.scientific.net/AMM.740 Customizing Dynamic Libraries of Qt Based on the Embedded Linux 10.4028/www.scientific.net/AMM.740.782