Chinaunix首页 | 论坛 | 博客
  • 博客访问: 182428
  • 博文数量: 63
  • 博客积分: 725
  • 博客等级: 军士长
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-12 19:55
文章分类

全部博文(63)

文章存档

2012年(35)

2011年(28)

分类: LINUX

2011-05-25 18:48:27

Hello World - Linux上的 MeeGo x86 开发

Contents

1 介绍

2 如何开发 (简要说明)

3 如何开发 (详细说明)

3.1 在你的机器上安装 MeeGo SDK

3.2 进入 MeeGo chroot 环境

3.3 运行模拟器

3.4 使用 Qt Creator 创建项目

3.5 在模拟器中运行程序

3.6在模拟器中调试程序

4 MeeGo实体设备开发说明

4.1 配置设备

4.2在设备上运行程序

4.3 在设备上调试程序

1.介绍

这个教程介绍了Linux下的 MeeGo x86 开发。教程解说了基本的开发流程,重点介绍了如何使用SDK附带的那些工具。教程不会涉及一些开发细节,例如 Qt 和 MeeGo 的 API、或是如何将程序整合到 MeeGo 环境中。

2.如何开发 (简要说明)

1) 获取并安装MeeGo SDK

2) 进入MeeGo SDK 环境

3) 启动模拟器

4) 启动Qt Creator

5) 使用Qt Creator 创建一个项目, 配置项目的 DISPLAY 环境变量,让项目能够在模拟器中运行。

6) 使用SDK的Qt 库编译项目。

7) 在模拟器中运行程序

在模拟器中为程序 Debug

9) 如果你有一台真实的MeeGo设备:

10) 准备设备

11) 在设备上运行程序

12) 在设备上为程序 Debug

3.如何开发 (详细说明)

3.1在你的机器上安装 MeeGo SDK

请参阅 在 Linux 上使用 MeeGo SDK 的介绍。

3.2进入 MeeGo chroot 环境

请参阅 这个介绍 。

3.3运行模拟器

把所有东西安装配置完成后,你应该可以在 MeeGo chroot 环境中运行模拟器了。

(3.1、3.2、3.3在上一篇日志中有详细介绍)

3.4使用 Qt Creator 创建项目

让 startmeego 脚本继续运行,然后启动 Qt Creator :

qtcreator &

这会在 host 上运行 Qt Creator (而不是在 Xephyr 里):

(缺图)

然后,配置一个新项目:

3.5在模拟器中运行应用程序

现在开始运行应用程序)

在Qt Creator中,点击左下角出绿色箭头,运行应用程序。

Qt Creator会先build程序,然后在Xephyr模拟的MeeGo桌面环境中运行程序

在模拟器中,你可能需要点击MyZone图标(房子图标)来显示运行的应用程序

(缺图)

3.6在模拟器中调试应用程序

用debug调试应用程序,让你看到应用程序在模拟器中的的运行情况。在前部分内容中,已经为我们Qt版本built了debugging helper,不然这里就不能使用debug调试程序。

点击bug图标(在工具条的左边)把Qt Creator设置为debug模式。在窗口上加上一些panel。

接下来,为了示意调试功能,在form上加上一个Push Button。

(缺图)

然后给Push Button加上了一个点击响应,以便点击Button的时候,消息字符串可以动态的在控制台上显示。代码如下:

/* file: Headers/mainwindow.h */

#ifndef MAINWINDOW_H

#define MAINWINDOW_H

#include

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

#include

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;

}

上面大部分代码由Qt Creator自动生成,这里只是定义了MainWindow::on_pushButton_clicked()函数,需要注意,必须在头文件中把此函数定义为私有的槽。

在需要调试的那行代码的编辑框边沿上点击,可以加上一个断点。 It looks like this:

(缺图)

点击绿色图标bug,在调试模式下运行应用程序。

(缺图)

点击button,程序停止在断点出。跳转回Qt Creator,查看debug页面。

(缺图)

注意Locals和Watchers tab如何输出消息变化为"I have been well and truly clicked")

有关Qt Creator的更多信息请查看[1]) .

4. MeeGo实体设备开发说明

如果你有一个MeeGo系统的设备,你也可以用Qt Creator运行调试你在设备上的的程序。

4.1配置设备

在使用Qt Creator之前,设备需要预先进行一些配置和安装一些软件包。在如下的命令行中完成这些工作:

1.为了可以使用SSH从Qt Creator中拷贝文件代码到设备中,你需要在设备(netbook)上安装OpenSSH服务:

sudo zypper install openssh-server

手动开启,否则只有重启后才会开启:

sudo /etc/init.d/sshd start

加入初始化序列,以便启动时候开启SSH服务:

sudo chkconfig --add sshd

2.如果你需要远程调试程序,就需要在netbook上安装gdbserver服务:

sudo zypper install gdb-gdbserver

4.2在设备上运行程序

仍然从chroot上启动Qt Creator,

1.选择工程,点击Project图标,显示出工程的配置框。

2.选择Run Setting)

3.点击Add drop-down,选择testapp)

4.Click on the Manage device configurations link to display the MeeGo Device Configurations dialog.

5.Click on the Add button (top-right) and complete the fields so they resemble the screenshot below:(缺图)(点击Add按钮(右上方),按照下图完成设置。)

You'll need to set Host Name to the IP address or domain name of the netbook, and enter the User Name and Password you used when you set up the netbook. The other options can be left at their defaults.(你需要设置Host Name到IP地址,或netbook名,输入上网本的用户名和密码。其他选项保持默认。)

6.Click on the Test button to check the connection. If it's configured correctly, you should see a message like the one in the screenshot above ("Device configuration successful").(点击Test按钮测试连接情况。如果设置没问题,你应该看到一个消息"Device configuration successful"

7.Click on OK to save your changes. This returns you to the Run Settings tab.(点击OK保存设置,返回Run Setting界面)

8.Select the new MeeGo netbook option from the Device Configuration drop-down.(从Device Configuration drop-down中选择新设置好的MeeGo上网本。)

Once you've completed this, you should be able to deploy and run the application on the netbook:(完成这些,你就可以远程调试运行上网本上的程序了。)

1.At the bottom-left of the Qt Creator window is a panel for selecting the build and run environments:(缺图)(在Qt Creator窗口的左下方,有一个按钮可以选择build和run环境。)

Click on the computer monitor icon, then use the arrows to select testapp on MeeGo device from the Run drop-down. The Build drop-down can be left at Debug .(点击电脑图标,)

2.Click on the green arrow (the normal run arrow) to deploy the application and run it. This copies the application binary to the home folder of the user you specified in the SSH settings and runs it.

If you can't see the application, it may be because it hasn't been given focus. You can use the zones icon in the toolbar to show the running application and select it.

Here's an example of what the application looks like running on a netbook:(缺图)

Debug the application on the device

This works almost the same on a remote device as it does inside the Simulator .

1.Configure the remote device as explained above .

2.In Qt Creator, click on the Target settings (bottom left with a monitor icon). Ensure you have Build set to Debug and Run set to testapp on MeeGo device (the remote device).

3.Click on the green arrow overlaid with a bug to start the application remotely in debug mode.

If you used the same code as above, try clicking on the Click me button in the application (running on the netbook). The application should pause at the breakpoint; and in Qt Creator, the message variable should then be visible in the Locals and Watchers tab, set to "I have been well and truly clicked". (No screenshot this time, as Qt Creator looks the same as it does for local debugging.)

文章转自: Intel博客
阅读(1196) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~