Windows下qt打包到Linux,Qt在linux和windows下的动态链接发布方式总结

Qt的进程发布主要有两种方式,Static Linking和Shared Libraries.其中静态链接的方式需要静态编译整个Qt库,我并没有这个耐心,所以到目前为止,我采用第二种方法比较多。本篇就记一下Ubuntu下发布Qt应用进程的方式。

#1.编译进程,以Release方式构建

构建完成之后,就可以提取构建文档夹中的可执行进程.

#2.写如下的一个脚本

1

2

3

4

5

6

7

8

9

10

11

12#!/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 "$@"

并将其改的和可执行文档同名.

#3.使用ldd命令查看当前可执行文档的依赖关系

注意,这里只需要将与qt相关的.so文档复制到发布文档夹下即可,并不需要将所有的依赖都找到.

这些依赖可能是由一个符号链接指向的,那么将指向的.so改为符号链接的名字是比较好用的方法

以上全部这些都需要手动来完成.

#4.打成一个压缩包,发布

1$tar -zcvf xxx.tar.gz xxx/

到这里,发布工作就算完成了

#在windows下的发布

windows下的发布其实更为简单一些,直接将所需要的动态链接库.dll找到放到文档夹内就可以了,有比较方便的工具可以简化操作,工具名称为windeployqt,下面是从帮助文档里摘抄来的一些信息

The Windows deployment tool can be found in QTDIR/bin/windeployqt. It is designed to automate the process of creating a deployable folder that contains all libraries, QML imports, plugins, translations that are required to run the application from that folder. This is used to create the sandbox for Windows Runtime or an installation tree for Windows desktop applications that can be easily bundled by an installer.

Usage: windeployqt [options] [files]

Qt Deploy Tool 5.4.0

The simplest way to use windeployqt is to add the bin directory of your Qt

installation (e.g. ) to the PATH variable and then run:

windeployqt If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH

variable. If your application uses Qt Quick, run:

windeployqt –qmldirbin>

Options:

-?, -h, –help Displays this help.

-v, –version Displays version information.

–dir Use directory instead of binary directory.

–libdir Copy libraries to path.

–debug Assume debug binaries.

–release Assume release binaries.

–release-with-debug-info Assume release binaries with debug information.

–force Force updating files.

–dry-run Simulation mode. Behave normally, but do not

copy/update any files.

–no-plugins Skip plugin deployment.

–no-libraries Skip library deployment.

–qmldir Scan for QML-imports starting from directory.

–no-quick-import Skip deployment of Qt Quick imports.

–no-translations Skip deployment of translations.

–no-system-d3d-compiler Skip deployment of the system D3D compiler.

–compiler-runtime Deploy compiler runtime (Desktop only).

–no-compiler-runtime Do not deploy compiler runtime (Desktop only).

–webkit2 Deployment of WebKit2 (web process).

–no-webkit2 Skip deployment of WebKit2.

–json Print to stdout in JSON format.

–angle Force deployment of ANGLE.

–no-angle Disable deployment of ANGLE.

–listPrint only the names of the files copied.

Available options:

source: absolute path of the source files

target: absolute path of the target files

relative: paths of the target files, relative

to the target directory

mapping: outputs the source and the relative

target, suitable for use within an

Appx mapping file

–verbose Verbose level.

Qt libraries can be added by passing their name (-xml) or removed by passing

the name prepended by –no- (–no-xml). Available libraries:

bluetooth clucene concurrent core declarative designer designercomponents

enginio gui qthelp multimedia multimediawidgets multimediaquick network nfc

opengl positioning printsupport qml qmltooling quick quickparticles quickwidgets

script scripttools sensors serialport sql svg test webkit webkitwidgets

websockets widgets winextras xml xmlpatterns webenginecore webengine

webenginewidgets

Arguments:

[files] Binaries or directory containing the binary.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值