在QT SDK下构建MeeGo Touch开发环境

移动开发
本文为你将介绍用QT4.7的SDK来搭建MeeGo Touch开发环境,编译QT4.7一般都需要大概一下午的时间,而是用SDK则最多不超过20分钟就搞定了。

在陆续推出MeeGo移动终端设备开发UI设计基础等教程之后,我们将为大家介绍一些MeeGo开发环境的教程。也许有不少朋友会问到,网上有不少构建MeeGo Touch环境的文章了,你又何必多此一举呢?细心的朋友可能会发现,我这里不用编译QT4.7 而是用QT4.7的SDK来搭建环境的。编译QT4.7一般都需要大概一下午的时间,而是用SDK则最多不超过20分钟就搞定了。这也是希望能有更快的方法让大家来玩MeeGo。

QT-sdk-linux-x86-opensource-2010.05-rc1.bin下载

1.安装 QT-sdk-linux-x86-opensource-2010.05-rc1.bin命令:

  1. chmod 777 QT-sdk-linux-x86-opensource-2010.05-rc1.bin  
  2. ./QT-sdk-linux-x86-opensource-2010.05-rc1.bin 

2.下载编译好的dbus库文件(附件里),放到QT 2010.05的库里。

安装g++

  1. sudo apt-get install g++ 

3.安装依赖库文件:

(1) 安装依赖库

  1. sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxrandr-dev libxrender-dev  
  2.  
  3.  
  4.  

(2) 安装dbus库

  1. sudo apt-get install libgconf2-dev libdbus-QT-1-dev  
  2.  

(3)修改libmeegotouch/configure,将HAVE_DBUS=no改为yes

修改libmeegotouch/configure

4.安装meegotouch-theme(这个主要是一些主题css文件等)

(1) 下载meegotouch-theme 代码

  1. git clone git://gitorious.org/meegotouch/meegotouch-theme.git    
  2.  

然后执行 chmod 777 -R libmeegotouch, 给下载下来的源码全部加上最高权限

(2) 进入目录meegotouch-theme。  

  1. cd meegotouch-theme/  
  2.  

(3) 执行qmake 生成makefile :

  1. qmake  
  2.  

(4) 安装

  1. sudo make install  
  2.  

说明:

在使用make的时候可能会说make的版本不是4.7。出现qmake与qt4的连接问题

可以敲下面命令测试

  1. $qmake -v  
  2.  

出现下面情况:

  1. $Qmake version: 1.07a (QT 3.3.8b)     
  2. $Qmake is free software from Trolltech ASA.  
  3.  

怎么qmake的版本变成了qt3了,进入/usr/bin目录下

  1. root@ubuntu:/home/yyy# cd /usr/bin  
  2. root@ubuntu:/usr/bin# ls -l qmake  
  3. lrwxrwxrwx 1 root root 23 2009-10-09 09:35 qmake -> /etc/alternatives/qmake  
  4.  

查看qmake的信息,它是一个链接指向的是/etc/alternatives/qmake

  1. root@ubuntu:/usr/bin# ls -l /etc/alternatives/qmake  
  2. lrwxrwxrwx 1 root root 18 2009-12-08 12:46 /etc/alternatives/qmake -> /usr/bin/qmake-qt3  
  3.  

终于找到的根源,原来qmake被设置成了qmake-qt3

#p#

强行修改

  1. root@ubuntu:/usr/bin# rm /etc/alternatives/qmake  
  2. root@ubuntu:/usr/bin# ln -s /usr/bin/qmake /etc/alternatives/qmake  
  3. root@ubuntu:/usr/bin# qmake -v  
  4. QMake version 2.01a  
  5. Using QT version 4.5.0 in /usr/lib  
  6.  

5.安装libmeegotouch

(1) 下载源代码

  1. git clone git://gitorious.org/meegotouch/libmeegotouch.git  
  2.  

然后执行 chmod 777 -R libmeegotouch, 给下载下来的源码全部加上最高权限

(2) 安装一些依赖的库。(根据个人PC的配置情况,以及后面2.4的配置结果,可能还需要安装其他的一些依赖库)

  1. sudo apt-get install libicu-dev graphviz  
  2.  

(3) 进入目录libmeegotouch。

  1. cd libmeegotouch 

(4) 进入目录,生成makefile :

  1. qmake  
  2.  

(5) 执行make 编译

  1. make  
  2.  

(6) 安装

  1. sudo make install  

在/usr/local/lib下的目录,发现已经生成的MeeGo 库文件

已经生成的MeeGo 库文件

实践:

1)写一个hello world代码

  1. main.cpp  
  2. #include <MApplication> 
  3. #include <MApplicationWindow> 
  4. #include <MApplicationPage> 
  5. #include <MLabel> 
  6.  
  7. int main(int argc, char **argv)  
  8. {  
  9. MApplication app(argc, argv);  
  10. MApplicationWindow window;  
  11. MApplicationPage page;  
  12.  
  13. page.setTitle("My First Page");  
  14. page.setCentralWidget(new MLabel("Hello World!"));  
  15. page.appear(&window);  
  16.  
  17. window.show();  
  18.  
  19.    return app.exec();  
  20. }  
  21.  
  22.  
  23. HelloWorld.pro  
  24.  
  25. ######################################################################  
  26. # Automatically generated by qmake (2.01a) ?? 9? 12 21:36:22 2010  
  27. ######################################################################  
  28. TEMPLATE = app 
  29. TARGET =   
  30. DEPENDPATH += .  
  31. INCLUDEPATH += .  
  32. CONFIG += meegotouch  
  33. # Input  
  34. SOURCES += main.cpp  
  35.  

如下图:

生成makefile文件

  1. qmake 

执行make

  1. make  
  2.  

运行程序 记得要加sudo

  1. sudo ./helloWorld 

程序结果如下:

程序结果

2) 编译一个编译example目录里面的 tutorial_music_catalogue 例子

(1) tutorial_music_catalogue这个例子程序,有详细的介绍文档, 在libmeegotouch的文档主页上,有个介绍 Your first MeeGo Touch application ,适合做为入门文档

(2) 由于libmeegotouch没有安装到标准路径下,因此需要修改它的pro工程文件,打开文件 tutorial_music_catalogue.pro,在里面添加如下一段(如果meegotouch的安装路径不一样,请自行对应修改):

  1. unix {  
  2. INCLUDEPATH += /usr/local/include/meegotouch  
  3. LIBS += -L/usr/local/lib -lmeegotouchcore -lmeegotouchextensions -lmeegotouchsettings -lmeegotouchviews  
  4. QMAKE_LFLAGS += -Wl,-rpath,/usr/local/lib  
  5. }  
  6.  

(3) 执行qmake

(4) 执行make,如果出现问题,可能是由于这个Makefile中需要调用mmoc。

  1. PATH=/usr/local/bin/:$PATH make 

(5) 运行tutorial_music_catalogue

  1. sudo ./tutorial_music_catalogue 

如果有花屏可以执行下面命令:

(并非所有的电脑都会黑屏或者花屏,所以运行程序的时候,可以自行尝试一下不同的情况)

  1. sudo ./tutorial_music_catalogue -software 

#p#

程序执行后的结果图:

第一页 
第一页

第二页
第二页

第三页 
第三页

(6) libmeegotouch程序通用的命令行参数。

  1.  
  2. MComponentData: Usage: ./tutorial_music_catalogue  
  3. [-software] Enable software rendering  
  4. [-fullscreen] Make the application fullscreen  
  5. [-show-br] Show the bounding rectangle for all scene items  
  6. [-show-fps] Show the FPS for the view (only with OpenGL rendering)  
  7. [-log-fps] Log the FPS for the application  
  8. [-show-size] Show widget sizes in the scene  
  9. [-show-object-names] Show the names of the objects in the scene  
  10. [-show-position] Show widget positions in the scene  
  11. [-show-cursor] Force the cursor to be visible  
  12. [-reverse] Change the layout direction to right-to-left direction  
  13. [-dev] Enable development visualization mode  
  14. [-genimglist filename] Generate list of requested images to filename  
  15. [-remote-theme] Wait until remote theme daemon is available  
  16. [-local-theme] Force usage of local theme processing instead of remote theme daemon  
  17. [-output-level debug|warning|critical] Only show messages of given output level or above  
  18. [-output-prefix <prefix>] Only show debug messages that start with the given prefix  
  19. [-no-output-prefix <prefix>] Only show debug messages that do not start with the given prefix  
  20. [-target <name>] Use the target device profile  
  21. [-prestart] Prestart the application (if supported)  
  22. [-fixed-orientation 0|90|180|270] Start application in fixed orientation.  
  23. This overrides keyboard state, as well as a device profile  

(7)  tutorial_music_catalogue这个示例程序很新,它依赖的QT版本和libmeegotouch版本,都高于目前MeeGo镜像中对 应的QT和libmeegotouch版本,因此在开发板上或虚拟机里并不能运行。但是,不妨碍我们用它来学习入门。example目录里面的其他示例程 序,在开发板上基本上都可以运行。

补充一些描述。

1 libmeegotouch是图形开发工具箱,从它的功能上来说,它相当于QT,gtk,clutter等这一类图形界面库。

2 libmeegotouch是基于QT的,准确点说是基于QT的graphicsview框架的,但是,它在graphicsview的基础上,又封装出 一层widget。在使用方法上和设计模式上,和原始的graphicsview或qwidget,并没有太多的交集。

3 开发MeeGo应用程序,如果没有QT开发经验,建议直接从libmeegotouch学起,在使用过程中,如果碰到了原始的QT中的class,再查阅 对应的手册。这种学习路线,消耗的时间应该是最少的。

4 另外,虽然在PC上可以安装libmeegotouch,但是这毕竟不是MeeGo的完整开发环境,它只负责MeeGo的GUI部分,因此这篇文档介绍的 方法,不能替代MeeGo的完整开发环境。之所以在PC上安装libmeegotouch,一方面是让许多没有硬件开发环境的朋友也可以在PC上体验一下 MeeGo的界面操作方式,另一方面,也是想说明一下MeeGo程序在开发上的灵活性,比如前端UI设计的时候,就可以先在PC上做一些原型设计。

[[15577]]

【编辑推荐】

  1. MeeGo移动终端设备开发UI设计基础教程
  2. Meego开发中安装Dropbox等应用详解
  3. 揭露关于MeeGo开发的15个事实
  4. 在Linux上使用MeeGo SDK进行Meego开发
  5. 虚拟机操作系统及Meego开发中MeegoSDK安装过程详解
责任编辑:佚名 来源: 米趣网
相关推荐

2011-06-16 16:41:20

Qt MeeGo SDK

2010-10-15 09:52:00

XephyrMeeGoQt

2010-07-02 12:58:39

Meego开发

2010-11-18 14:47:49

2010-08-30 13:46:09

MeeGoMeeGo Touch

2011-08-15 10:14:41

Sencha ToucMyEclipseTomcat

2010-10-22 10:02:14

诺基亚Qt开发者

2010-11-17 09:29:31

linux Fedora 13Ubuntu 10.0

2011-06-08 14:06:42

linux SDK Qt

2010-05-02 14:29:15

Meego开发

2015-06-01 12:10:57

dockerhexo

2011-03-18 20:13:01

QtUbuntu

2011-06-29 10:18:20

LINUX QT ARM

2010-06-22 13:46:39

Meego开发

2011-06-16 17:19:33

Qt Meego

2011-06-03 13:38:49

Android 开发环境

2010-06-02 11:02:01

SVN开发环境

2009-07-17 17:39:35

在NetBeans环境

2010-09-25 09:31:27

EclipseAndroid

2011-06-17 11:00:18

Qt Linux Ubuntu
点赞
收藏

51CTO技术栈公众号