简体   繁体   English

在linux上部署Qt项目

[英]Deploy a Qt project on linux

This may be a noob question, but I have been stuck trying to work out how to statically build my qt project on linux. 这可能是一个noob问题,但我一直在试图找出如何在linux上静态构建我的qt项目。 I tried doing what it said on http://doc.qt.io/qt-5/linux-deployment.html , but I do not understand the 1st step. 我试着在http://doc.qt.io/qt-5/linux-deployment.html上做了什么,但我不明白第一步。 When I cd to the location of my qt project and run 当我cd到我的qt项目的位置并运行

cd /path/to/Qt
./configure -static -prefix /path/to/Qt <otherparameters>
make
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. 我想让我的qt项目成为一个独立的可执行文件,它不需要它所拥有的计算机有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? 部署选项在qtcreator中显示为灰色,有没有办法使用它? Thanks 谢谢

/path/to/Qt should be the path to Qt's sources, not your project's. /path/to/Qt应该是Qt源的路径,而不是你的项目的路径。 That section of the documentation is about building Qt statically, which you must do before trying to statically link your application to Qt. 文档的这一部分是关于静态构建Qt,在尝试将应用程序静态链接到Qt之前必须执行此操作。 For example, if you downloaded/cloned the sources to /home/jxb458/qt5 , then you'd replace /path/to/Qt with that: 例如,如果您将源代码/克隆到/home/jxb458/qt5 ,那么您可以将/path/to/Qt替换为:

cd /home/jxb458/qt5
./configure -static -prefix /home/jxb458/qt5/qtbase
make

Static linking is great when it works, but it can be an effort - I have found especially when using GUI. 静态链接在工作时很棒,但它可能是一种努力 - 我特别在使用GUI时发现。 As Mitch said you need to actually re-build the Qt source code 正如Mitch所说,你需要重新构建Qt源代码

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. 当我在这里静态构建时,我做了一些注意事项: 关于静态构建的注释 (源自许多来源)它们至少应该指向正确的方向 - 你可以忽略关于安装Ubuntu的部分 - 注意假设一个新安装。

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). 您不需要在目标机器上安装Qt,只需要收集qt dll并将其与您的应用程序一起复制(使用ldd executable-name生成您需要的dll列表 - 但只需使用Qt而不是系统/通用的)。 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). 我甚至写了一个bash脚本自动执行此操作(如果需要,我会发送给你),在windows中有一个名为windeployqt的qt脚本(不知道为什么没有linux变种)。

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). 也许尝试一个简单的项目开始(像一个hello world proj)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM