Saturday, 11 October 2014

Qt: Static Linking - Nine ways to fail rebuilding Qt to enable static builds...

The case of static building for Qt is discussed below. With Qt installed, the environment provides the needed DLL-s automatically.

Specifying the DLL-s separately for deployment on a non-Qt environment is very complicated. If I'll deploy my projects in the future, that will most likely be in a single exe file, possibly with some resource files. Therefore, I need to get the static deployment working.

To make this possible, the entire Qt source code needed to be recompiled. This process takes many hours.

Initially, I had Qt installed with the compiler set to Microsoft Visual Studio Express 2013, and having the 64-bit version of Qt installed.

After several hours of compiling all the source code, the compilation process crashed. The first issue was that plugins such as SQL didn't compile during the rebuild of Qt. This is a major issue for deploying applications.

At the next attempt (re-installing Qt and rebuilding it with SQL disabled), I got another crash after five hours, complaining that a LIB file was missing. I even tried to reverse-engineer the LIB file from the dll file, but that wasn't successful either.

Even after following the instructions at
http://doc-snapshot.qt-project.org/qtifw-master/ifw-getting-started.html#configuring-qt
the compilation crashed, this time since a stddev.h file wasn't accepted by the compiler.

I tried with both 64/32-bit versions and MinGW32 (Minimalist GNU for Windows) and Microsoft Visual Studio-based Qt framework, without any luck.

This process took me several days. Why mentioning it on the blog? One central part of software development is all the dead-ends and failures in setting up the development environment. For hobby projects it isn't as critical as in commercial projects, where the developer sometimes need to explain for the stakeholders why he/she has spent several days, barking on the wrong tree.

I'll post the success-story in the next blog post.

No comments:

Post a Comment