问题描述
这可能是一个菜鸟问题,但是我一直在努力研究如何在Linux上静态构建我的qt项目.我尝试按照 http://doc.qt.io/qt-5/linux-deployment.html ,但我不了解第一步.当我cd到我的qt项目的位置并运行时
This may be a noob question, but I have been stuck trying to work out how to statically build my qt project on linux. I tried doing what it said on http://doc.qt.io/qt-5/linux-deployment.html , but I do not understand the 1st step. When I cd to the location of my qt project and run
cd /path/to/Qt
./configure -static -prefix /path/to/Qt <
otherparameters>
make
它说没有这样的文件或目录.我是否误解了需要使用的路径?我想让我的qt项目成为一个独立的可执行文件,它不需要装有qt的计算机.我已经读过关于动态链接库的信息,但是我也不知道该怎么做.qtcreator中的deploy选项为灰色,有没有办法使用它?谢谢
it says no such file or directory. Am I misunderstanding what paths I need to use? I want to make my qt project a stand alone executable which doesnt require the computer it is on to have qt. I have read about dynamically linking the libraries, but I dont really know what to do with that either. The deploy option is greyed out in qtcreator, is there a way to use this?Thanks
推荐答案
静态链接在工作时非常有用,但这是一种努力-我发现特别是在使用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
当我在此处进行大量静态构建时,我记下了一些笔记:有关静态构建的说明(来自许多来源),它们至少应指向正确的方向-您可以可能会忽略有关安装Ubuntu的部分-注释假定为新安装.
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).
这篇关于在Linux上部署Qt项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!