Qt shadow builds

From Qt Wiki
Revision as of 07:19, 10 February 2015 by Maintenance script (talk | contribs)
Jump to navigation Jump to search

How to set up shadow builds on OS X and Linux

Qt has a wonderful option: you can build Qt depending on your need from the same source code in many different flavors.

It come with a -prefix option in its configure script, which will allow you to install Qt in a directory of your choice. E.g. if you want to build a different version of Qt with or without webkit, you can do so by using the -no-webkit option in configure and by defining a different installation path using -prefix.

This way you build different versions of Qt on your development machine from the same source code.

Unfortunately, this option is not available on Windows.

How to set up shadow builds on Windows

While developing for Windows you might want to compile a version of Qt for several different platforms and SDKs. In order to create those different builds of Qt you do not have to copy the whole Qt package or the Qt source. You are able to create multiple Qt builds from a single source tree. Such builds are called shadow builds.

Basically a shadow build is created by calling configure.exe from a different directory.

To make sure that the shadow build compiles correctly it is important that you following these guidelines:

  • Required Build tools : Get & Install either MSYS or MSYS2 shell (do not use both, unless you know what you are doing).
    • Toolchains/Compilers : Either get Visual Studio, or, MinGW, or, MinGW-w64 [qt.io] toolchains, (or get all of them, based on your need & target), separately from their official websites & install, or, get & Install MinGW-w64 (64bit & 32bit) toolchains inside MSYS2-shell. And add their directory location in the PATH environment variable.
    • Option-A : Either get Perl, Ruby, Python, msysgit, 7zip separately from their official site and install into separate directories, and add each separate directories into the PATH. (ActivePerl [activestate.com] , StrawberryPerl [strawberryperl.com] , etc are a popular distribution of Perl on Windows).
    • Option-B : or, get & install Perl, Ruby, Python, git, 7pzip, etc inside MSYS2-shell with just one command and add just one directory location in PATH.
    • Get & install other build related tools, SDKs, dependencies, etc which you need for your target platform(s). And add their directory location in PATH and also add other build related environment variables (like INCLUDE, LIB, LIBPATH, DEV, QTDIR, etc). See Qt build related other articles. For example, you may need support for OpenSSL ICU [qt.io] (Unicode), etc.
      • Bring %SystemRoot% location (its $SYSTEMROOT inside cygwin/bash/msys2) in beginning of PATH:
        • If you are using Cmd-Shell, run this command:
        • If you are using MSYS2-Shell, run this command:
      • If you are using jom, fart, etc tools then:
        • If you are using Cmd-Shell, run this command:
        • If you are using MSYS2-Shell, run this command:
      • set the PATH
        • If you are using Cmd-shell, then adjust & run/execute below command:
        • If you are using MSYS2-shell (or MSYS-shell), then adjust & run/execute below command:
  • The original Qt source package must be left untouched – the “configure” must never have been run inside the source tree directory.
    • For example, lets assume, we are handling with Qt version number %VERSION%, where %VERSION% variable contains version number 5. So we will place our source files in this directory: C:\Qt\Qt%VERSION%_src which means C:\Qt\Qt5_src (/c/Qt/Qt5_src).
      • To set version number run/execute below command, for Cmd-shell:
      • To set version number run/execute below command, for MSYS2-shell:
      • If you are using windows Cmd-shell, then you need to run/execute similar commands
      • If you are using MSYS2-shell or MSYS shell, then you need to run/execute similar commands
  • With Qt5, the code has to be checked out of the git repository, otherwise the out of source build will fail as syncqt is not executed.
  • Avoid using “release” and “debug” in the path to the shadow build directory. (This is an internal limitation of the build system.)
  • So lets assume you have installed Qt in C:\Qt\Qt%VERSION%_src and you want to create a shadow build in C:\Qt\mobile-Qt5-shadow:
    • Make sure the environment variables for your build & target platform related compiler/toolchains, tools, dependencies, etc are set.
      • For example, in Cmd-shell:
      • For example, in MSYS2-shell:
      • Visual Studio includes vcvars32.bat for that purpose – or simply use the “Visual Studio Command Prompt” from the Start menu.
  • Now navigate and GO INSIDE into your shadow build directory and run the “configure”:
    • If you are using Cmd-shell:
      Adjust above command for your target platform, above is for building Qt5 for Windows CE platform.
    • If you are using MSYS2-shell (or MSYS-shell) :
      Adjust above command for your target platform, above is for building Qt5 for Windows CE platform.
  • Finally, to build the shadow build, you may use nmake or jom or mingw32-make. In below example, we are showing command for nmake only:
  • That’s all. You have successfully created a shadow build of Qt inside C:\Qt\mobile-Qt5-shadow.
  • Now you can call “nmake install” and get a clean installation of Qt inside INSTALLDIR.

Categories: