Meego Development Guide 1.0 development tutorial

Source: Internet
Author: User
Meego Development Guide 1.0 development tutorial transferred from: meego Chinese

Introduction

To get a development overview of the meego platform, the best place is meego developers. Here we will discuss more detailed issues, such as the details of meego APIs.

 

Meego Application Development tutorial
  • (1) Use meego SDK on Linux
Introduction

The meego SDK consists of the following parts:

  1. A meego chroot environment that contains a meego application Simulator Based on xephyr (http://www.freedesktop.org/wiki/Software/Xephyr) (Linux only), scripts for starting/stopping meego desktops in xephyr, and QT creator that can remotely configure and deploy the meego device.
  1. Start the meego chroot environment and runMeego-SDK-chrootScript.

To install the meego SDK, download the package version of these components. This will be discussed in the next section.

 

System Requirements

To run the meego simulator in xephyr, you need a newer Linux release (such as fedora 11, UBUNTU 9.10) and Intel hardware environment. The hardware environment has the following requirements:

  • CPU: 32bit Intel (r) atom (TM) or Intel (r) core (TM) 2 CPU (support for ssse3)

    • Note: The meego simulator cannot run on a CPU that does not support ssse3.
  • A compatible Intel graphics card. GMA-500, NVIDIA, and ATI chipset are not supported

This is the meego simulator requirement, not the SDK requirement. I can run the meego SDK on an AMD processor and NV graphics card and compile/debug the program normally.

 

Install the meego chroot environment

The meego chroot package is a large file (close to 800 mb ). It not only has all the library files of meego itself, but also other useful things (xephyr, scripts, QT creator ).

Download the meego chroot package:

wget http://download3.meego.com/meego-sdk-0524.tar.bz2

Decompress the meego chroot package:

tar zxvf meego-sdk-0524.tar.gz

Another solution is to create a meego chroot by yourself. For details, see building a meego chroot on Linux.

 

Install meego-SDK-chroot script

Meego-SDK-chrootThe script sets the mount point of the chroot environment, and then starts the root environment in an appropriate way. When leaving the chroot environment, it will try to correctly uninstall the entire environment, and clear the processes started in the chroot environment.

Download:

wget http://download3.meego.com/meego-sdk-chroot

Execute the script:

chmod +x meego-sdk-chroot

Move/Usr/bin:

mv meego-sdk-chroot /usr/bin

 

Configure the host for the simulator

The next step is to configure the host's X environment so that the simulator (running in the chroot environment) can be correctly displayed on the screen of normal users:

xhost +local:

(After each restart, You need to perform this step before running the simulator and QT creator)

 

Enter the meego chroot environment

Meego-SDK-chrootThe script will set up a meego chroot environment and give you a shell in this environment:

sudo meego-sdk-chroot ~/meego-sdk-0524

(Replace the above 'with your chroot directory'~ Meego-sdk-0524)

Note that this script uses the chroot command. Sometimes, the root user cannot locate this command in the PATH environment variable (in fedora, the chroot command/Usr/sbinPath ). You canMeego-SDK-chrootAdd a line alias at the top of the script to solve this problem:

alias chroot='/usr/sbin/chroot'

After the script is run, the following content is output:

mount --bind /proc /home/ell/meego-sdk-0524/procmount --bind /sys /home/ell/meego-sdk-0524/sysmount --bind /dev /home/ell/meego-sdk-0524/devmount --bind /dev/pts /home/ell/meego-sdk-0524/dev/ptsmount --bind /tmp /home/ell/meego-sdk-0524/tmpmount --bind /var/lib/dbus /home/ell/meego-sdk-0524/var/lib/dbusmount --bind /var/run/dbus /home/ell/meego-sdk-0524/var/run/dbuscp /etc/resolv.conf /home/ell/meego-sdk-0524/etc/resolv.confroot@meego-netbook-sdk:/#

 

Install other software

You can install the software normally in the chroot environment (the same as the latest netbook image ).
Go to the chroot environment and run:

zypper install <package>

The following command updates the entire meego image to the latest version:

zypper dist-upgrade

 

Running Simulator

In the chroot environment, run the following command as root:

startmeego &

This will start the xephyr server and run a script. This script starts a meego desktop in xephyr.

If you want to start a program in the chroot environment and display it in the simulator window, you can:

DISPLAY=:2 glxgears

(Replace glxgears with the program name you want to start)

 

Debugging in the simulator

If a problem occurs in your simulator, you can use the debug script to see what happened:

startmeego-debug

This script will output some information in the console, which should give you clues to the problem.

 

Netbook UX interface in the simulator

It looks like this:

 

Detected problems:

  • Some tool bar components (such as batteries and networks) dependent on the gauge cannot report the working status of the device.

 

Stop Simulator

To stop the simulator, you only need to leave the chroot shell:

exit

This will stop all processes started by the simulator and uninstall the path used by the chroot environment. This will output the following information:

exitumount /home/ell/meego-sdk-0524/procumount /home/ell/meego-sdk-0524/sysumount /home/ell/meego-sdk-0524/dev/ptsumount /home/ell/meego-sdk-0524/devumount /home/ell/meego-sdk-0524/tmpumount /home/ell/meego-sdk-0524/var/lib/dbusumount /home/ell/meego-sdk-0524/var/run/dbus
  • (2) Introduction to meego x86 development on Hello world-Linux

    This tutorial introduces meego x86 development in Linux. The tutorial explains the basic development process and focuses on how to use the tools attached to the SDK.

    The tutorial does not involve some development details, such as the APIs of QT and meego, or how to integrate programs into the meego environment.

    How to Develop (brief description)
    • Get and install meego SDK
    • Go to the meego SDK Environment
    • Start the simulator
    • Start QT creator
    • Use QT creator to create a project and configure the display environment variable for the project to run in the simulator.
    • Use the QT library of the SDK to compile the project.
    • Run the program in the simulator
    • Debug the program in the simulator

    If you have a real meego device:

    • Prepare the device
    • Run the program on the device
    • Debug the program on the device

    How to Develop (details)

    Install meego SDK on your machine

    See introduction to using meego SDK on Linux.

    Enter the meego chroot environment

    See this introduction.

    Running Simulator

    After installing and configuring everything, you should be able to run the simulator in the meego chroot environment.

    Use QT creator to create a project

    Let the startmeego script continue to run, and then start QT Creator:

    qtcreator &

    This will run QT Creator on the host (instead of in xephyr ):

     

    Configure a new project:

    • Create a new project (File> New file or project). InProjectsIn the dialog box, selectQt GUI applicationAnd then clickOK.
    • InputHelloworldAs the project name, select a directory for saving the project (for example, if you use the root account to work, you can select/Root). Then clickNext.
    • PersistenceClass InformationIn the dialog box, clickNext.
    • InProject ManagementIn the dialog box, clickFinish.

    Enter some code:

    • OpenFormsDirectory, double-clickMainwindow. UIOpen the graphic form editor.
    • Drag a label from the component list on the left of the form editor and place it on the edited form.
    • Modify the label text ("Hello world" is a good choice ).
    • Drag a few more things you like.

    Then configure the project:

    • Click on the left side of the QT creator windowProjectsIcon.
    • Configure the QT version:
      • InBuild Settings> GeneralClickMoreButton. This displays the QT library version used in the current project.
      • ClickQt versionTag edgeManageButton.Qt versionsPanel:
      • SelectedQt In PathProject.
      • ClickRebuildButton to createDebugging helper.
      • ClickOKSave settings.
    • ConfirmQt version, It should beDefault QT version (QT In Path).
    • Then, configure the running environment and use the simulator to display the running program:
      • ClickRun settingsLabel.
      • ClickRun EnvironmentThe followingMoreButton.
      • Double-clickDisplayIn the environment variable area, Set0.0Change: 2. This allows QT creator to run the program in the display area 2, that is, xephyr.

    Run the program in the simulator

    Now you are ready to run the program.

    In QT creator, click the big green arrow in the lower left corner to run the program. At the first run, this will compile the entire project (using the QT library version you set), and then: 2Display program (that is, the meego simulator in xephyr.

    In the simulator, the program may run in the background and will not be directly displayed on the screen. In this case, you can click the myzone icon to activate the program:

     

    Debug the program in the simulator

    After you start the program in QT creator, If you activate the debug mode, you can monitor the running status of the program.

    In the previous section, we have created debugging helper for the QT library of the current version. This must be done in advance, or you will not be able to debug the program.

    Click the bug icon in the left-side toolbar to activate the debug mode of QT creator. This adds a panel in the window to display the running stack, variable and expression values, and other useful information.

    Then, you need some bugs for debugging. I addedPush Button:

     

    Then, a click event is added for this button. When you click this button, a string variable is printed to the console. The Code is as follows:

    /* file: Headers/mainwindow.h */#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>namespace Ui {    class MainWindow;}class MainWindow : public QMainWindow {    Q_OBJECTpublic:    explicit MainWindow(QWidget *parent = 0);    ~MainWindow();protected:    void changeEvent(QEvent *e);private:    Ui::MainWindow *ui;private slots:    void on_pushButton_clicked();};#endif // MAINWINDOW_H
    /* file: Sources/mainwindow.cpp */#include "mainwindow.h"#include "ui_mainwindow.h"#include <QDebug>#include <QString>MainWindow::MainWindow(QWidget *parent) :    QMainWindow(parent),    ui(new Ui::MainWindow){    ui->setupUi(this);}MainWindow::~MainWindow(){    delete ui;}void MainWindow::changeEvent(QEvent *e){    QMainWindow::changeEvent(e);    switch (e->type()) {    case QEvent::LanguageChange:        ui->retranslateUi(this);        break;    default:        break;    }}void MainWindow::on_pushButton_clicked(){    QString message;    message = "I have been well and truly clicked";    qDebug() << message;}

    Most of the Code is inherited from the original project, onlyMainwindow: on_pushbutton_clickedThis method is added by myself. Note that I also defined a private slot in the header file.

    Note: signals and slots are concepts in QT. For more information, see the Introduction to QT.

    In the editor, click on the left of the statement you want to debug to add a breakpoint. It looks like this:

     

    (Note the red circle on the left of 34 rows)

    Click the Green Arrow with the bug sign (in the lower left corner) to start the program in debug mode. The program will be displayed in the simulator:

     

    Now, in the program window of the simulator, clickPush ButtonThis will interrupt the program on the breakpoint just set. Go back to QT creator and check the debug panel:

     

    We can see thatLocals and watchersLabel,MessageThe variable value has been set to "I have been well and truly clicked.

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.