How to package your QT project and install it in the meego System

Source: Internet
Author: User
Tags rpmbuild

Introduction

 

This article will teach you how to package your QT project and install it on the meego device. Here, we use an OpenGL project named "Textures" in the QT example as an example. This original project is a QT example without icons that cannot be started from the meego UI. We will make it look more like an independent application.Program, Which can be started directly from the meego application panel and installed on the meego device in RPM package format.

Preparations

The preparation material is an example of QT demo contained in the QT-example package, which is located in/usr/lib/qt4/example/OpenGL/textures.

Copy it to your $ workspace directory as an independent project. It can be either meego SDK chroot or a Linux machine with QT-examples installed.Code:

 

    1. CP-A/usr/lib/qt4/examples/OpenGL/textures $ workspace/textures-0.0.1
    2. CD $ workspace/textures-0.0.1

Copy code


Add an icon for the program. Here we use the project icon in the example as our application icon.

 

 

    1. CP images/side6.png textures.png

Copy code


Add a desktop file so that we can find our program in the meego application panel.

 

 

    1. Vim textures. Desktop

Copy code


Content:

 

 

    1. [Desktop entry]
    2. Name = qtdemotextures
    3. Comment = QT demo textures
    4. Exec = textures
    5. Categories = development;
    6. Icon = textures
    7. Type = Application
    8. Terminal = false
    9. Startupnotify = true

Copy code


Edit the textures. Pro file to remove some definitions used in QT example and add icons and desktop installation.

 

 

    1. Vim textures. Pro

Copy code


The modified content is as follows:

 

 

    1. Headers = glwidget. h \
    2. Window. h
    3. Sources = glwidget. cpp \
    4. Main. cpp \
    5. Window. cpp
    6. Resources = textures. qrc
    7. Qt + = OpenGL
    8. # Install
    9. # Target. Path = $ [qt_install_examples]/OpenGL/textures
    10. # Sources. Files = $ sources $ headers $ resources $ forms textures. Pro Images
    11. # Sources. Path = $ [qt_install_examples]/OpenGL/textures
    12. Target. Path = $ [install_prefix]/bin
    13. Icon. Files = textures.png
    14. Icon. Path = $ [install_prefix]/share/icons
    15. Desktop. Files = textures. Desktop
    16. Desktop. Path = $ [install_prefix]/share/Applications
    17. Instols + = target icon Desktop

Copy code


If you want to test it before packaging, you can build and debug it under meego SDK chroot. For details, see meego x86 development on Hello world-Linux.

 

 

    1. Qmake prefix =/usr
    2. Make
    3. Make install

Copy code


Clean up the project, create the source code compressed package, and prepare for packaging.

 

 

    1. Make distclean
    2. CD ..
    3. Tar jcvf textures-0.0.1.tar.bz2 textures-0.0.1

Copy code


Create a spec File

 

Meego recommends that you use the spectacle tool to create a meego spec file or convert an existing spec file to a meego spec file.

Install spectacle

You can install it directly on the meego platform or meego chroot environment.

 

    1. Yum install Python-Cheetah
    2. Yum install spectacle

Copy code


If you are a proxy, you need to set it before running the preceding command:

 

 

    1. Export http_proxy = http: // proxy_server: Port

Copy code


For details about how to install the software on a Linux host, see spectacle installation.

 

Create a yaml package Metadata File

Spectacle uses the package metadata file as the input to generate the meego spec file. This metadata file is in yaml format. For syntax, see Syntax of spectacle yaml.

Create a textures. yaml file under $ workspace/folder.

 

    1. Vim $ workspace/textures. yaml

Copy code

The content is as follows:

    1. Name: textures
    2. Summary: QT demo-OpenGL textures
    3. Version: 0.0.1
    4. Release: 1
    5. GROUP: Development/tools
    6. License: lgplv2.1
    7. URL: [url = http://qt.nokia.com] http://qt.nokia.com [/url]
    8. Sources:
    9. -"Registry.name=-registry.version=.tar.bz2"
    10. Description: QT demo OpenGL textures
    11. Pkgconfigbr:
    12. -Qtcore> = 4.6.0
    13. -Qtopengl
    14. -Qtgui
    15. Configure: None
    16. Builder: None
    17. Files:
    18. -"% {_ Bindir}/Textures"
    19. -"% {_ Datadir}/applications/*. desktop"
    20. -"% {_ Datadir}/icons/*. PNG"

Copy code


The yaml file can also be created from an existing spec file.

 

 

    1. Spec2spectacle package_name.spec

Copy code

For details about spectacle usage, see spectacle usage.

 

Generate a spec file from the yaml File

Using the yaml file, it is easy to generate the spec file:

 

    1. Specify textures. yaml

Copy code

The generated $ workspace/textures. spec file contains the following content:

 

 

  1. #
  2. # Do not edit! Generated:
  3. # Spectacle version 0.15
  4. #
  5. #>> Macros
  6. # <Macros
  7. Name: textures
  8. Summary: QT demo-OpenGL textures
  9. Version: 0.0.1
  10. Release: 1
  11. GROUP: amusements/graphics
  12. License: lgplv2.1
  13. URL: [url = http://qt.nokia.com] http://qt.nokia.com [/url]
  14. Source0: registry.name=-registry.version=.tar.bz2
  15. Source100: textures. yaml
  16. Requires (post): desktop-file-utils
  17. Requires (post):/bin/touch
  18. Requires (postun): desktop-file-utils
  19. Buildrequires: pkgconfig (qtcore)> = 4.6.0
  20. Buildrequires: pkgconfig (qtopengl)
  21. Buildrequires: pkgconfig (qtgui)
  22. Buildrequires: desktop-file-utils
  23. % Description
  24. Qt demo OpenGL textures
  25. % Prep
  26. % Setup-Q-N % {name}-% {version}
  27. #>> Setup
  28. # <Setup
  29. % Build
  30. #>> Build pre
  31. # <Build pre
  32. #>> Build post
  33. # <Build post
  34. % Install
  35. Rm-RF % {buildroot}
  36. #>> Install pre
  37. # <Install pre
  38. #>> Install post
  39. # <Install post
  40. Desktop-file-install -- delete-original \
  41. -- Dir % {buildroot} % {_ datadir}/applications \
  42. % {Buildroot} % {_ datadir}/applications /*
  43. % Post
  44. /Bin/touch -- no-create % {_ datadir}/icons/hicolor |:
  45. % {_ Bindir}/GTK-Update-icon-Cache \
  46. -- Quiet % {_ datadir}/icons/hicolor 2>/dev/null |:
  47. Update-desktop-database % {_ datadir}/Applications &>/dev/null |:
  48. % Postun
  49. /Bin/touch -- no-create % {_ datadir}/icons/hicolor |:
  50. % {_ Bindir}/GTK-Update-icon-Cache \
  51. -- Quiet % {_ datadir}/icons/hicolor 2>/dev/null |:
  52. Update-desktop-database % {_ datadir}/Applications &>/dev/null |:
  53. % Files
  54. % Defattr (-, root, root ,-)
  55. % {_ Bindir}/textures
  56. % {_ Datadir}/applications/*. Desktop
  57. % {_ Datadir}/icons/*. PNG
  58. #> Files
  59. # <Files

Copy code

Modify the textures. spec file to add the QT construction information: "build pre" and "Install Post" segments.

 

 

    1. #>> Build pre
    2. Export Path =/usr/lib/qt4/bin: $ path
    3. Qmake prefix =%{_ prefix}
    4. # <Build pre

Copy code

 

    1. #>> Install post
    2. Make install_root = % {buildroot}/usr install
    3. # <Install post

Copy code

 

Build RPM under meego SDK chroot

For application developers, it is very easy to directly create packages in the meego SDK chroot environment through rpmbuild.

First, enter the chroot environment.
Install rpmbuild and meego RPM build configuration

 

    1. Zypper install rpm-build
    2. Zypper install meego-rpm-config

Copy code

 

Copy the source code and spec file to the correct location

 

    1. CP textures-0.0.1.tar.bz2 ~ /Rpmbuild/sources/
    2. CP textures. yaml ~ /Rpmbuild/sources/
    3. CP textures. spec ~ /Rpmbuild/specs/

Copy code

 

Generate RPM package

 

    1. Cd ~ /Rpmbuild/specs
    2. Rpmbuild-Ba textures. spec

Copy code


This RPM package will be generated in:

 

 

    1. ~ // Rpmbuild/RPMS/i586/textures-0.0.1-1.i586.rpm
    2. ~ /Rpmbuild/srpms/textures-0.0.1-1.src.rpm

Copy code

 

More rpmbuild use parameter copy: rpmbuild

Create an RPM package without using chroot or obs

For some build or release users, they may want to build RPM packages that do not require the meego SDK chroot environment. The steps are as follows:

Linux

In Linux, a tool called "build" can directly create an RPM package from the spec file.

@ Install build on your host.
@ Create an RPM package using the build tool and spec File

 

    1. Sudo build -- repository [url = repository -- arch i686 textures. spec

Copy code

 

This package will be generated in/var/tmp/build-root/home/abuild/rpmbuild/RPMS/AND/var/tmp/build-root/home/abuild/rpmbuild/srpms /directory, you can configure your http_proxy to ensure the repo is successful.

 

    1. Export http_proxy = http: // proxy_server: Port

Copy code


Verify RPM package

 

The RPM package can be directly installed on the meego device or in the meego SDK simulation program, copied to the target device or simulator, and run.

 

    1. Zypper -- no-GPG-Checks install textures-0.0.1-1.i586.rpm

Copy code

 

In this case, you can find qtdemotextures in programming under applications, which has been included.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.