C

Linking to Static Builds of Qt

The device-specific toolchain and image in Boot to Qt come with a dynamically linked version of Qt libraries (*.so files). In some cases, using static linking may be preferable; it avoids the dependencies to external libraries, produces single, self-contained application binaries making deployment easier, and may lead to smaller binary size as unused code can be stripped away.

Internally, Qt uses dynamic linking with plugins for a lot of its functionality. In order to have a fully functioning application, extra attention is needed on which plugins to include in a static build. A downside of static linking is that adding or updating a plugin requires a complete rebuild and redeployment of the application.

Building Qt for Static Linking

Before you can build your static Qt application, you will need to rebuild the toolchain and device image with static configuration. See Building Static Version of Qt for configuring the Qt to be static and How to Create Boot to Qt Image for build the toolchain and image.

Building a Static Application

Building a stand-alone, static application requires all the necessary plugins to be also statically linked. By default, all the plugins from Qt modules which are used in your project are included.

For more information, see Static Plugins.

Adding QML Imports

Similar to how Qt plugins are imported, build invokes the qmlimportscanner tool to scan the application's .qml files, and generates a <target_name>_qml_plugin_import.cpp file containing a Q_IMPORT_PLUGIN() call for each static plugin associated with a QML import.

For example, for a simple QML application using the QtQuick and QtQuick.Window import statements, the following statements are generated:

Q_IMPORT_PLUGIN(QtQuick2Plugin)
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)

Available under certain Qt licenses.
Find out more.