且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Linux上部署Qt项目

更新时间:2022-12-02 14:28:40

静态链接在工作时非常有用,但这是一种努力-我发现特别是在使用GUI时.正如Mitch所说,您实际上需要重新构建Qt源代码

Static linking is great when it works, but it can be an effort - I have found especially when using GUI. As Mitch said you need to actually re-build the Qt source code

当我在此处进行大量静态构建时,我记下了一些笔记:

I made some notes back when I was building statically quite a bit here: Notes on static building (derived from many sources) they should at least point you in the right direction - you can probably ignore the part about installing Ubuntu - the notes assume a new install.

但是,最近我又回到了动态链接部署,因为我认为这是现在更好的部署方式.您不需要在目标计算机上安装Qt,只需要收集Qt dll并将其复制到您的应用程序中(使用 ldd可执行文件名称即可生成所需的dll列表-但仅取Qt而不是系统/通用的).对于插件,您需要做更多的事情(但是相当简单).我什至编写了一个bash脚本来自动执行此操作(如果需要,我会将其发送给您),在Windows中有一个名为windeployqt的qt脚本(不确定为什么没有Linux变体).

However I have more recently returned to the dynamic linking deployment since I feel this is a better way to deploy now. You don't need to install Qt on the target machine you just need to collect the qt dlls and copy them with your application (using ldd executable-name which produces a list of dlls you need - but just take the Qt ones not the system/generic ones). For plugins you need to do a bit more (but its fairly simple). I even wrote a bash script to do this automatically (i'll send it to you if you need it), in windows there is a qt script called windeployqt (not sure why there is not a linux variant).

如果我从哪里开始重新研究部署,我将进行动态链接.也许可以尝试从一个简单的项目开始(例如hello world proj).

If I where to start again looking into deployment I would go for dynamic linking. Maybe try with a simple project to start with (like a hello world proj).