手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

X11/Linux下发布Qt程序(Deploying Qt Applications for X11/Linux)

[日期:2010-08-27] 来源:Linux社区  作者:午小夜 [字体:大 中 小]

在X11平台下发布QT程序,首先准备好程序中需要使用的资源,库和插件。

比如你的可运行程序取名叫作panel,那把你的panel,那些libQt*.so.4和libQt*.so.4.6.0(链接和共享库都要)放在同一目录下(也可以不同,只要小小修改下shell文件).plugins就不多说了。

在程序的同目录下,新建一个空文档,取名panel.sh (文件名与程序名同名,扩展名为sh,shell文件).
在panel.sh中原封不动的写入以下语句:

#!/bin/sh
appname=`basename $0 | sed s,\.sh$,,`
dirname=`dirname $0`
tmp="${dirname#?}"
if [ "${dirname%$tmp}" != "/" ]; then
dirname=$PWD/$dirname
fi
LD_LIBRARY_PATH=$dirname
export LD_LIBRARY_PATH
$dirname/$appname $*

保存文件,退出.在终端给文件+x属性: 切换到程序的目录,输入
chmod +x panel.sh
然后运行shell文件就行了(确保panel程序具备X属性),它会自动更改环境变量,运行程序.
如果要调试shell文件,只需要在终端输入:
sh -x panel.sh
这样就ok了.

关于plugins,有以下3种处理方法:
# Using qt.conf. This is the recommended approach since it provides the most flexibility.
# Using QApplication::addLibraryPath() or QApplication::setLibraryPaths().
# Using a third party installation utility or the target system's package manager to change the hard-coded paths in theQtCore library.

第二种方法很简单。qt.conf的方法也不错.看看这个:


Entry Default Value
Prefix QCoreApplication::applicationDirPath()
Documentation doc
Headers include
Libraries lib
Binaries bin
Plugins plugins
Data .
Translations translations
Settings .
Examples .
Demos .

最简单的qt.conf文件这样写就好了:(插件在当前文件夹下的plugins文件夹里)
[Paths]
Prefix = .
Plugins = plugins

好了.大功告成!

linux
相关资讯       Qt  Linux编程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款