Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

static linking Qt with open source version [closed]

Tags:

licensing

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.

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.

like image 243
martin Avatar asked Sep 29 '12 17:09

martin


People also ask

Can you statically link Qt?

Building Qt for Static LinkingTo use static linking, Qt must be built with the -static configuration option. The following configure command selects the correct options and sysroot for the Raspberry Pi 2.

Is Qt still open source?

The Qt framework is available under both open source and commercial licenses.

Can I use Qt open source license for commercial?

The Qt framework is dual-licensed, available under both commercial and open-source licenses. The commercial license is recommended option for non-open source projects. If you consider using Qt under any open source licenses, please read this document carefully.

Can I use the free Qt for C++ commercially?

As long as you can comply with the (L)GPL requirements of the Qt libraries, then you do not need to purchase a "commercial license" from the Qt Company. Note that the terminology "commercial license" is a bit ambiguous, because the (L)GPL license also allows 'commercial' use as long as you can follow the obligations.


1 Answers

EDIT April 2016

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.

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.

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.

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:

  • your Qt build only contains modules, licensed under LGPL, and nothing GPL
  • the about section of your app mentions that it is using Qt and contains a link to where you can download the application's object files
  • include all the respective license files with your application

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.

Update:

Here is an excerpt directly from the GNU FAQ:

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

(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.

That states it pretty clear.


The old, original answer:


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.

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.

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

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.

like image 63
dtech Avatar answered Sep 19 '22 14:09

dtech