The project currently uses the GNU autotools as build system.
There are two main ways to build the library: from a git repository checkout and from a source release tarball.
Before you can compile the libqmi library, you will need at least the following tools:
- A compliant C toolchain: e.g.
- pkg-config, a tool for tracking the compilation flags needed for libraries.
- The glib2 library.
- For libqmi git master builds, glib2 >= 2.56.
- For libqmi >= 1.26, glib2 >= 2.48.
- For libqmi >= 1.18 and < 1.26, glib2 >= 2.36
- For libqmi >= 1.0 and < 1.18, glib2 >= 2.32
In addition to the previous mandatory requirements, the project also has several optional dependencies that would be needed when enabling additional project features:
- libmbim, in order to use the QMI-over-MBIM feature.
- For libqmi >= 1.22, libmbim >= 1.18.
- For libqmi >= 1.16 and < 1.22, libmbim >= 1.14.
- libqrtr-glib, in order to use the QMI-over-QRTR feature.
- For libqmi >= 1.28, libqrtr-glib >= 1.0.
- The libgudev library, in order to extend the
qmi-firmware-updateoptions and behavior.
- For libqmi git master builds, libgudev >= 232.
- For libqmi >= 1.18, libgudev >= 147.
- gtk-doc tools, in order to regenerate the documentation.
- gobject-introspection, in order to generate the introspection support.
When building from a git checkout instead of from a source tarball, the following additional dependencies are required:
The basic build and installation of the project can be done from an official release source tarball, in the following way:
$ wget https://www.freedesktop.org/software/libqmi/libqmi-1.28.2.tar.xz $ tar -Jxvf libqmi-1.28.2.tar.xz $ cd libqmi-1.28.2 $ ./configure --prefix=/usr $ make
Additional optional switches that may be given to the
configure command above would be:
- In Debian/Ubuntu systems the default location for libraries depends on the architecture of the build, so instead of the default
/usr/libpath that would be in effect due to
--prefix=/usr, the user should also give an explicit
--libdirpath pointing to the correct location. E.g. on a 64bit Ubuntu/Debian build, the user would use
- If the QMI-over-MBIM feature is required, the additional
--enable-mbim-qmuxshould be given. Omitting this switch will imply auto-detecting whether the feature can be built with the already installed dependencies.
- If the QMI-over-QRTR feature is required, the additional
--enable-qrtrshould be given. Omitting this switch will imply auto-detecting whether the feature can be built with the already installed dependencies.
- If the project should build support for only a certain subset of QMI commands, the user can select which collection of commands should be used with the
--enable-collection=minimalwill select the minimum number of QMI commands required to have a data connection up.
--enable-collection=basicwill select the minimum number of QMI commands required by ModemManager.
--enable-collection=full, or omitting the switch, will select all the available QMI commands.
--enable-collection=XXXXwill select the QMI commands listed in the user-provided
data/qmi-collection-XXXX.jsonfile in the project sources.
- If the documentation should be rebuilt, the additional
--enable-gtk-docswitch should be given. Omitting this switch will imply auto-detecting whether the documentation can be rebuilt with the already installed dependencies.
- If the introspection support should be included in the build, the additional
--enable-introspectionswitch should be given. Omitting this switch will imply auto-detecting whether the introspection can be built with the already installed dependencies.
- When developing changes to the library or debugging issues, it is recommended to build with debug symbols so that running the program under
gdbproduces useful backtrace information. This can be achieved by providing user compiler flags like these:
An example project build using all the above optional switches could be:
$ ./configure \ --prefix=/usr \ --libdir=/usr/lib/x86_64-linux-gnu \ --enable-mbim-qmux \ --enable-qrtr \ --enable-collection=basic \ --enable-gtk-doc \ --enable-introspection \ CFLAGS="-ggdb -O0" $ make
./configure --help will show all the possible switches that are supported.
Building from a git checkout
When building from a git checkout, there is one single additional step required to build the project: running the included
autogen.sh in order to setup the GNU autotools project and generate a
$ git clone https://gitlab.freedesktop.org/mobile-broadband/libqmi.git $ cd libqmi $ NOCONFIGURE=1 ./autogen.sh $ ./configure --prefix=/usr $ make
The same optional switches may be given to the
configure script when building from a git checkout.
The installation on the prefix selected during
configure can be done with the following command:
$ sudo make install
Please note that the command above will install the library in the system default path for libraries, possibly overwriting any previous libqmi library that may already exist from a package manager installed package.
Installing in /usr/local
If no explicit
--prefix is given to the
configure command when preparing the build, the default
/usr/local path will be used as prefix, which will avoid needing to overwrite the package manager installed files. If this approach is taken, the developer can keep the package manager installed library in
/usr/lib and the package manager installed command line tool in
/usr/bin, while keeping the custom installed library in
/usr/local/lib and the custom installed command line tool in
Under this scenario, the user can run the package manager installed
qmicli in the following way, which will use the package manager installed library from
In the same scenario, the user can run the custom installed
qmicli in the following way, which will use the custom installed library from
$ LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/qmicli
But beware because there are distributions like Debian/Ubuntu which add the
/usr/local/bin path to the
PATH environment variable by default, so running the following command would attempt to run the custom installed
qmicli with the package manager installed library from
/usr/lib (which is obviously a mess and won’t probably work):
This complication with the need of the explicit
LD_LIBRARY_PATH is the reason why this guide suggests to overwrite the package manager installed files.
If you have manually installed the project with the steps above, it can be uninstalled in the same way:
$ sudo make uninstall
If the manual install overwrote the package manager installed files, it is suggested to force a re-install of the corresponding packages at this point, so that the system is not left with missing files.
Since libqmi 1.10.0, the libqmi library is always API/ABI compatible, so installing a newer version (e.g. self compiled) of the library on a system that has other packages depending on an older version will not break the setup.
Installing an older version of the library on a system that has other packages depending on a newer version may obviously break the setup, though.