静态链接Qt与开源版本 [英] static linking Qt with open source version

查看:223
本文介绍了静态链接Qt与开源版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Qt开源版本开发应用程序.由于我不想交付Microsoft Visual Visual C(++)可再发行组件,因此我想使用静态链接的Qt版本. Qt许可信息我要使用商业Qt许可开发"在我的应用程序中进行静态链接,尽管当我使用configure -static命令构建静态Qt库时,命令提示符会询问我是否使用商业版或开源版本的Qt.

I'm developing an application with the Qt open source edition. As I don't want to deliver the Microsoft Visual Visual C(++) redistributables, I'd like to use a static-linked version of Qt. The Qt licensing information says that I "should" develop with a commercial Qt license if I want to use static linking in my application, although when I use the configure -static command for building a static Qt library the command prompt asks me if I use the commercial or open source version of Qt.

因此可以使用开放源代码版本构建Qt吗?我是否需要商业版才能使用静态链接?我不会出售该应用程序.

So it is possible to build Qt with the open source version? Do I need the commercial edition to use static linking? I won't sell the application.

推荐答案

EDIT 2016年4月

EDIT April 2016

实际上,我最近一直在深入了解LGPL,并向该领域的一些专家询问.事实证明,无法在封闭源代码应用程序中对Qt使用静态链接的现象更多地是源远流长,与现实无关.

Actually, I have recently been reading in depth about LGPL, and asking some experts on the subject. Turns out that the inability to use static linking for Qt in closed source applications is more of a cultivated legend and has nothing to do with reality.

LGPL所需要的是最终用户可以将应用程序重新链接到库的其他版本.使用动态链接是实现此目的的一种方法,但是您可以轻松地提供目标文件,而不必打开源代码,并且LGPL要求仍然得到满足.

What LGPL requires is the possibility for the end user to relink the application against a different version of the library. Using dynamic linking is one way to achieve that, but you can just as easily provide your object files, this way you don't have to open your source and the LGPL requirement is still satisfied.

在Qt网站上有2个法律常见问题解答,但都没有直接说明您不能这样做.正如没有说您可以.但是,至少有几种情况暗示您隐含了法律威胁.我认为所有这些都有很好的解释-他们不能说如果不发布实际谎言就无法做到这一点,这可能会对他们产生负面的法律影响,并且他们愿意劝阻这样做而不是鼓励这样做,因为它有可能迫使更多人购买商业许可证.

On the Qt website there are 2 legal FAQs and in neither of them is it directly stated that you can't do it. Just as it is not stated that you can. However, there are at least several instances of implying a vague legal threat in case that you do. I think there is a good explanation for all of those - they can't say that you can't do it without publishing a practical lie which may as well have negative legal repercussions for them, and they are willing to discourage doing that rather than encourage it, as it has the potential to force more people into purchasing a commercial license.

简而言之,是可以,而且肯定是应该,因为最近Qt变成了活跃的部署地狱,加上从静态版本开始的Qt 5.7, QML文件被整齐地塞在可执行文件中,而不是放在文件系统中,任何人都可以对其进行篡改.只需确保:

So in short, yes you can, and you most definitely should as lately Qt has become a living deployment hell, plus as of Qt 5.7 in a static build, QML files are tucked neatly in the executable rather than being out on the file system, for anyone to tamper with. Just make sure that:

  • 您的Qt版本仅包含获得LGPL许可的模块,没有GPL
  • 应用程序的关于"部分提到它正在使用Qt,并包含一个链接,您可以在其中下载该应用程序的目标文件
  • 在您的应用程序中包含所有各自的许可证文件

最后,您的应用程序实际上必须是可重新链接的",也就是说,它必须能够与提供必要功能的兼容库版本一起使用.这意味着,如果您在构建Qt之前已对其进行了修改,则还必须以源代码的形式提供这些内容,但只能提供对Qt的修改,而不是应用程序的源代码.

Lastly, your application actually has to be "relinkable", that is, it must be able to work with a compatible library version that provides the necessary functionality. Which means that if you have made modifications to Qt before building it, you must provide those in the form of source code as well, but only the modifications to Qt, not your application's source code.

更新:

以下是 GNU FAQ 的摘录:

为了遵守LGPL(任何现有版本:v2, v2.1或v3):

For the purpose of complying with the LGPL (any extant version: v2, v2.1 or v3):

(1)如果您静态链接到LGPL库,则还必须在一个对象(不一定是源代码)中提供您的应用程序 格式,以便用户有机会修改库和 重新链接应用程序.

(1) If you statically link against an LGPL'd library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.

这很清楚.

原始的原始答案:

只要您的应用程序是开源的并且您提供源代码,就可以静态地构建Qt.如果您想关闭源代码,则要么需要昂贵的商业许可证,要么需要使用动态链接.

It is possible to build Qt statically as long as your application is open-source and you provide the source. If you want to keep your source closed, you either need an expensive commercial license, or you need to use dynamic linking.

使用Qt静态构建的BTW非常好,对于Qt5,我可以获得大约7-8 MB的可执行文件,而没有外部依赖关系,这比动态链接的应用附带的20+ MB附加dll好得多.

BTW using a static build of Qt is pretty nice, for Qt5 I get about 7-8 MB executable with no external dependencies, which is much better than the 20+ MB of additional dll's you have to ship with a dynamically linked app.

有关更多信息,请观看以下视频:在开发时选择正确的许可证与Qt

For more information, you can take a look at this video: Making the correct license choice when developing with Qt

总而言之,可以做到吗? 100%是.应该做吗?取决于个人/测试/学习的目的,这是100%可以的,但是,如果您打算分发生产级软件,无论是否商业化,是否开源,您最好先咨询律师.整个主题不必要地复杂,需要解释,因此与律师的咨询要比昂贵的商业许可证昂贵.

All in all, can it be done? 100% yes. Should it be done? It depends, for personal/testing/learning purposes it is 100% OK, however if you plan to distribute production grade software, be that commercially or not, open source or not, you'd better first consult with a lawyer. The whole subject is unnecessarily complicated, subject to interpretation, so that the consultation with a lawyer becomes more expensive than a pricey commercial license.

这篇关于静态链接Qt与开源版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆