Search code examples
qtqt6

How to compile qtimageformats?


The recently released Qt 6.0.0 has changed the distribution of the qtimageformats. Thay are no longer prebuilt and have to be built locally.

I checked out the QT git sources as described here.

git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout v6.0.0

Then, I edited the .gitmodules file and changed the qtimageformats' ignore flag to the 'addon'. I found out that the configure script is based on the .gitmodules and these flags.

[submodule "qtimageformats"]
    depends = qtbase
    path = qtimageformats
    url = ../qtimageformats.git
    branch = dev
    status = addon

I setup the required build environment per the Qt doc.

REM Set up Microsoft Visual Studio 2019, where <arch> is amd64, x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64
SET _ROOT=C:\Qt6\Qt5
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
REM Uncomment the below line when using a git checkout of the source repository
REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
SET _ROOT=

Then, I retrieved all git modules as described in Qt docs.

perl init-repository

Until now - all works as expected. The configure help really shows the qtimageformats options.

configure --help
...
...
Further image format options:

  -jasper .............. Enable JPEG-2000 support using the JasPer library [no]
  -mng ................. Enable MNG support [no]
  -tiff ................ Enable TIFF support [system/qt/no]
  -webp ................ Enable WEBP support [system/qt/no]

However, now I'm stuck on the following error. It seems that those options are not recognized by the configure?

c:\qt6\qt5>configure.bat -tiff qt
+ cd qtbase
+ c:\qt6\qt5\qtbase\configure.bat -top-level -tiff qt
CMake Error at qtbase/cmake/QtProcessConfigureArgs.cmake:227 (message):
  Unknown command line option '-tiff'.
Call Stack (most recent call first):
  qtbase/cmake/QtProcessConfigureArgs.cmake:531 (qtConfAddError)

Qt 6 has no documentation regarding the qtimageformats - so I missed probably something but don't know what. Any idea is welcome!


Solution

  • Finally, I was successful. I found the Phoronix article about Qt6.

    Qt6 started to use the conan.io package manager. So the sources provided by the Qt installer are sufficient. It downloads sources of the qtimageformats to the following location ~/Qt/AdditionalLibraries/Qt/qtimageformats-6.0.0.

    Conan will do the rest.

    MacOS [shared libs]

    cd ~/Qt/AdditionalLibraries/Qt/qtimageformats-6.0.0/Src
    export QT_PATH=~/Qt/6.0.0/clang_64
    ~/Qt/Tools/Conan/conan install . -o qtimageformats:shared=True
    ~/Qt/Tools/Conan/conan build .
    

    PS: The install command is really before the build command - that is not a mistake.

    Libraries were built successfully on MacOS.


    Windows [shared libs]

    CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
    SET QT_PATH=C:\Qt\6.0.0\msvc2019_64
    cd C:\Qt\AdditionalLibraries\Qt\qtimageformats-6.0.0\Src
    md build
    cd build
    C:\Qt\Tools\Conan\conan install .. -s build_type=RelWithDebInfo
    C:\Qt\Tools\Conan\conan build ..
    C:\Qt\Tools\Conan\conan build ..
    

    PS: The first conan build command will fail since the generated cmake files are not suitable for the parallel building. The second conan build command will succeed. If you now, how to convince the conan.io to disable parallel building without the conanfile.py, let us know.