IANAL
A commonly misunderstood aspect of LGPL is that it requires dynamic linking. It doesn't. It merely requires the ability for the party that got the code to relink it with the LGPL'd libraries that they were able to rebuild from the source that you used and provide to build the Qt that ships with your application.
Dynamic linking takes care of that by definition, as the linking is performed every time on application startup (prelinking is only a cache), and the library's source is available (in the distribution's package).
So, all you need to do is to split your application into two projects:
A static library project (.a) that contains all of your code. This is the closed source part.
An application executable that links the static library with the Qt library, C++ runtime, etc. At this point it's immaterial whether the Qt library is statically or dynamically linked.
To be compliant with LGPL, your users must be able to obtain, per terms of LGPL, all of the files necessary to perform step #2 (in the simplest case just a .pro file!), and the static library (.a) from step #1.
In fact, step #2 makes it very easy to provide a platform-specific way of linking your project with locally installed Qt. For example, if you were targeting RedHat systems, you could use the following script:
#! /bin/bash
# MiroProject.sh
yum install qt5-devel
qmake MiroProject
make install
The project file could look as follows, assuming that the static library resides in the same place as MiroProject.pro
and dummy.cpp
.
# MiroProject.pro
template = app
LIBS += -L. -lMiroProject
SOURCES += dummy.cpp
You need a to reference at least one symbol in the static library to have it link. This also avoids a different problem peculiar to MSVC. For example:
// dummy.cpp
int main(int argc, char ** argv);
void dummy__reference() {
main(0, 0);
}
A minimum package requires four files: MiroProject.sh
- the script above, MiroProject.a
from step #1, dummy.cpp
and MiroProject.pro
. And of course you must provide the sources for the Qt library that you've built MiroProject.a
with.
Ideally, your package should include the whole shebang: Qt sources, your closed-source .a
or .lib
, the open-source wrapper, and a script that builds it all.
IANAL