教你如何将你的Qt项目打包安装在MeeGo系统中
简介
本文将教你怎样将你写的Qt项目打包并安装在MeeGo设备上运行。这里通过Qt示例中一个名叫"textures"的OpenGL项目来为例来讲述。这个原始项目是一个没有图标不能从MeeGo UI 启动的Qt例子,我们将使它看起来更像一个独立的应用程序,可以从MeeGo 应用程序面板中直接启动并且以rpm包格式安装在MeeGo设备上。
前期准备
准备材料是一个包含在qt-example包中的Qt demo例子,具体位置在 /usr/lib/qt4/example/opengl/textures。
将它拷贝到你的$workspace目录下做为一个独立的项目。既可以是MeeGo SDK chroot下也可以是安装qt-examples的linux机器上。代码:
- cp -a /usr/lib/qt4/examples/opengl/textures $workspace/textures-0.0.1
- cd $workspace/textures-0.0.1
复制代码
为程序添加图标,此处我们使用例子中的项目图标作为我们的应用程序图标。
- cp images/side6.png textures.png
复制代码
添加一个桌面文件,可以使我们在MeeGo应用程序面板中找到我们的程序。
- vim textures.desktop
复制代码
内容是:
- [Desktop Entry]
- Name=QtDemoTextures
- Comment=Qt Demo Textures
- Exec=textures
- Categories=Development;
- Icon=textures
- Type=Application
- Terminal=false
- StartupNotify=true
复制代码
编辑textures.pro文件,去除一些用于Qt Example中的定义并且加入图标、桌面安装。
- vim textures.pro
复制代码
修改后的内容如下:
- HEADERS = glwidget.h /
- window.h
- SOURCES = glwidget.cpp /
- main.cpp /
- window.cpp
- RESOURCES = textures.qrc
- QT += opengl
- # install
- #target.path = $[QT_INSTALL_EXAMPLES]/opengl/textures
- #sources.files = $SOURCES $HEADERS $RESOURCES $FORMS textures.pro images
- #sources.path = $[QT_INSTALL_EXAMPLES]/opengl/textures
- target.path = $[install_prefix]/bin
- icon.files = textures.png
- icon.path = $[install_prefix]/share/icons
- desktop.files = textures.desktop
- desktop.path = $[install_prefix]/share/applications
- INSTALLS += target icon desktop
复制代码
如果你想在打包之前测试下,你可以在MeeGo SDK chroot下构建调试,请参考: Hello World - Linux上的 MeeGo x86 开发
- qmake PREFIX=/usr
- make
- make install
复制代码
清理项目,创建源码压缩包,准备打包。
- make distclean
- cd ..
- tar jcvf textures-0.0.1.tar.bz2 textures-0.0.1
复制代码
创建spec文件
MeeGo推荐使用Spectacle工具创建MeeGo spec文件或者将一个存在的spec文件转换成MeeGo spec文件。
安装Spectacle
在MeeGo 平台 或 MeeGo chroot 环境,可以直接安装。
- yum install python-cheetah
- yum install spectacle
复制代码
如果您是代理,那么在运行上面命令之前需要设置:
- export http_proxy=http://proxy_server:port
复制代码
在Linux主机上安装,可以参考: Spectacle Installation
创建 YAML 包元数据文件
Spectacle使用包元数据文件作为输入来产生MeeGo spec 文件,这个元数据文件是YAML格式的,语法参见: Syntax of Spectacle YAML.
我们在$workspace/folder下创建一个textures.yaml文件
- vim $workspace/textures.yaml
复制代码
内容如下:
- Name: textures
- Summary: Qt Demo - OpenGL Textures
- Version: 0.0.1
- Release: 1
- Group: Development/Tools
- License: LGPLv2.1
- URL: [url=http://qt.nokia.com]http://qt.nokia.com[/url]
- Sources:
- - "%{name}-%{version}.tar.bz2"
- Description: Qt Demo OpenGL Textures
- PkgConfigBR:
- - QtCore >= 4.6.0
- - QtOpenGL
- - QtGui
- Configure: none
- Builder: none
- Files:
- - "%{_bindir}/textures"
- - "%{_datadir}/applications/*.desktop"
- - "%{_datadir}/icons/*.png"
复制代码
YAML文件也可以从已存在的spec文件创建
- spec2spectacle package_name.spec
复制代码
Spectacle详细用法请参考: Spectacle Usage
从YAML文件生成spec文件
使用YAML文件,很容易生成spec 文件:
- specify textures.yaml
复制代码
生成的$workspace/textures.spec 文件内容是:
- #
- # Do not Edit! Generated by:
- # spectacle version 0.15
- #
- # >> macros
- # << macros
- Name: textures
- Summary: Qt Demo - OpenGL Textures
- Version: 0.0.1
- Release: 1
- Group: Amusements/Graphics
- License: LGPLv2.1
- URL: [url=http://qt.nokia.com]http://qt.nokia.com[/url]
- Source0: %{name}-%{version}.tar.bz2
- Source100: textures.yaml
- Requires(post): desktop-file-utils
- Requires(post): /bin/touch
- Requires(postun): desktop-file-utils
- BuildRequires: pkgconfig(QtCore) >= 4.6.0
- BuildRequires: pkgconfig(QtOpenGL)
- BuildRequires: pkgconfig(QtGui)
- BuildRequires: desktop-file-utils
- %description
- Qt Demo OpenGL Textures
- %prep
- %setup -q -n %{name}-%{version}
- # >> setup
- # << setup
- %build
- # >> build pre
- # << build pre
- # >> build post
- # << build post
- %install
- rm -rf %{buildroot}
- # >> install pre
- # << install pre
- # >> install post
- # << install post
- desktop-file-install --delete-original /
- --dir %{buildroot}%{_datadir}/applications /
- %{buildroot}%{_datadir}/applications/*
- %post
- /bin/touch --no-create %{_datadir}/icons/hicolor || :
- %{_bindir}/gtk-update-icon-cache /
- --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
- update-desktop-database %{_datadir}/applications &> /dev/null || :
- %postun
- /bin/touch --no-create %{_datadir}/icons/hicolor || :
- %{_bindir}/gtk-update-icon-cache /
- --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
- update-desktop-database %{_datadir}/applications &> /dev/null || :
- %files
- %defattr(-,root,root,-)
- %{_bindir}/textures
- %{_datadir}/applications/*.desktop
- %{_datadir}/icons/*.png
- # >> files
- # << files
复制代码
修改textures.spec文件添加qt 建构信息:"build pre"和"install post" 段。
- # >> build pre
- export PATH=/usr/lib/qt4/bin: $PATH
- qmake PREFIX=%{_prefix}
- # << build pre
复制代码
- # >> install post
- make INSTALL_ROOT=%{buildroot}/usr install
- # << install post
复制代码
在MeeGo SDK chroot 下构建rpm
对于应用程序开发者来说,他们可以在MeeGo SDK chroot环境下直接创建包,通过rpmbuild是非常容易的。
首先进入chroot环境。
安装rpmbuild和MeeGo rpm 构建配置
- zypper install rpm-build
- zypper install meego-rpm-config
复制代码
拷贝源码和spec文件到正确的地方
- cp textures-0.0.1.tar.bz2 ~/rpmbuild/SOURCES/
- cp textures.yaml ~/rpmbuild/SOURCES/
- cp textures.spec ~/rpmbuild/SPECS/
复制代码
生成rpm包
- cd ~/rpmbuild/SPECS
- rpmbuild -ba textures.spec
复制代码
这个rpm包将生成在:
- ~/rpmbuild/RPMS/i586/textures-0.0.1-1.i586.rpm
- ~/rpmbuild/SRPMS/textures-0.0.1-1.src.rpm
复制代码
更多的rpmbuild使用参拷:rpmbuild
不用chroot 或 OBS 构建 rpm包
对于一些构建或release的人来说,他们可能想去构建不需要MeeGo SDK chroot环境的rpm包,那么步骤如下:
Linux
在Linux下,有一个工具叫“build”可以直接从spec文件创建rpm包。
@在你的主机上安装build。
@利用build工具和spec文件创建rpm包
- sudo build --repository [url=http://repo.meego.com/MeeGo/release/1.0/core/repo/ia32/os/]http://repo.meego.com/MeeGo/release/1.0/core/repo/ia32/os/[/url] --arch i686 textures.spec
复制代码
这个包将被生成在/var/tmp/build-root/home/abuild/rpmbuild/RPMS/ 和 /var/tmp/build-root/home/abuild/rpmbuild/SRPMS/目录下,你可以配置你的http_proxy来确保repo成功。
- export http_proxy=http://proxy_server:port
复制代码
验证rpm包
rpm包可以被直接安装在MeeGo设备上或MeeGo SDK模拟程序中,拷贝rpm到目标设备或模拟器上并运行。
- zypper --no-gpg-checks install textures-0.0.1-1.i586.rpm
复制代码
此时你可以在applications下的Programming中找到QtDemoTextures,它已经被列入其中了。
源文: http://wiki.meego.com/Packaging/Tutorial
教你如何将你的Qt项目打包安装在MeeGo系统中相关推荐
- 如何将你的Qt项目打包安装在MeeGo系统中
简介 本文将教你怎样将你写的Qt项目打包并安装在MeeGo设备上运行.这里通过Qt示例中一个名叫"textures"的OpenGL项目来为例来讲述.这个原始项目是一个没有图标不能从 ...
- 教你如何3分钟把VUE项目打包成apk,真的只要3分钟
前提准备 使用vue-cli3搭建的项目 工具 HBuilder X,他的图标长这个样子,点击下载 做前端的大多数小伙伴们都应该知道,使用起来轻巧.急速,但是他主要是针对于VUE生态打造的,相对于 v ...
- 使用idea打包war包和maven项目打包war包放到tomcat中运行,以及报404错误的解决
使用idea打包war包和maven项目打包war包放到tomcat中运行,以及报404错误的解决 在tomcat下运行打包的war包,访问时显示404 浅谈打包war包的方式 第一种: 第一步: 第 ...
- Qt项目打包发布超详细教程
文章目录 前期准备工作 一.发布方式 (一)手动发布 (二)windeployqt发布 二.打包成.exe安装包 注意:后面的所有语句中涉及到编译器的,请大家自行替换成自己用的编译器,我这里使用的是M ...
- 转:教大家如何用HBuilder将web项目打包成apk
链接:https://www.jianshu.com/p/d86bf569295d 将我们的web项目打包成一个apk文件并不难,首先准备好软件HBuilder还有你的项目,注意这里只献给那些不是真正 ...
- python项目打包部署到linux系统_把python项目打包到linux执行-女性时尚流行美容健康娱乐mv-ida网...
女性时尚流行美容健康娱乐mv-ida网 mvida时尚娱乐网 首页 美容 护肤 化妆技巧 发型 服饰 健康 情感 美体 美食 娱乐 明星八卦 首页 > 高级搜索 webpack 打包 node. ...
- Qt 5.14 安装,windows10系统,64位,详细步骤,非常简单!
下载地址:http://download.qt.io/archive/qt/5.14/5.14.2/ 直接选择windows系统或mac兄或Linux系统对应版本即可. 这里解释一下 Qt 的版本号, ...
- linux java jar包项目如何安装在win系统 设置开机自启等配置 - jar包配置不用改
大家都知道 linux 是没有c盘或者d盘 我们部署linux项目的时候 , java 上传的文件都是在当前项目的目录下, 我们需要把项目部署到win系统的时候 在不改其jar包的配置下,在指定盘 ...
- vs2019中如何创建qt项目_在VS2015中创建Qt项目【VS+Qt项目开发系列】(二)
在VS2015中创建Qt项目[VS+Qt项目开发系列](二) 发布时间:2018-04-20 22:44, 浏览次数:1269 , 标签: VS Qt 在上一篇[VS+Qt项目开发](一)在VS201 ...
最新文章
- LINQ to SQL 运行时动态构建查询条件
- Python的装饰器
- mysql嵌套实战_艰难的mysql嵌套表结果挑战
- Spring 使用 JSR303自定义校验注解+分组校验
- 从十四五规划看 物联网(NB-IoT、Cat.1、5G)将何去何从?
- Docker容器数据卷讲解
- 单链表的回文判断(O(n)时间复杂度和O(1)的空间复杂度)
- WINDOWS XP数字总线补丁 KB888111
- 计算机无法连上网怎么办,电脑显示已连接上但是无法上网怎么办
- linux内核的挂载,通过Linux内核使用RDT
- OSPO Summit 2022 正式启动!OSPO Summit 2022 Launched!
- sicily 9562 SUME
- 아 / 어/여서与고 的区别
- 以水稻为例教你如何使用BSA方法进行遗传定位(上篇)
- 国际标准SHARE78七级灾难备份方案
- SLIC超像素分割的算法介绍和源码分析
- 网吧看电影你们都用什么IT网站看网吧电影会员免费免VIP的那种
- 计算机电路板 接地,pcb电路板接地怎么接
- “大数据”挖出老鼠仓的政治价值
- 计算机ipad手机组成,如何为自适应手机,计算机和iPad制作网页的摘要
热门文章
- 网站域名备案需要多长时间?个人经验分享
- 2021年电工(初级)考试内容及电工(初级)模拟考试题
- 7个半月股价涨了40%多,DXC做对了什么?
- 一起做RGB-D SLAM(4)
- 卡牌游戏源代码(原创)(控制台)
- Python中既有列表,何必再有数组(NumPy‘s ndarray)?
- MATLAB强化学习工具箱(一)-在网格环境中使用Q-learning and SARSA
- 先谈云计算再谈云大会
- [免费专栏] Android安全之Android so文件分析「详细版」
- Vue2 的 diff 算法