Build Instructions jpeg xl - cocoon/jxl.Net GitHub Wiki

Build Instructions

Always check current issues

new Home: https://github.com/libjxl/libjxl/issues

  • 0.3.3:
  1. https://gitlab.com/wg1/jpeg-xl/-/issues/165 (apply with: git apply < patchfilename.diff)
  2. https://gitlab.com/wg1/jpeg-xl/-/issues/166#note_523689644

Official instructions

Visual Studio 2019

Prerequisites

CMAKE GUI

Install vcpkg

How to

  • Clone from GitHub: git clone https://github.com/Microsoft/vcpkg
  • Run the bootstrap script in the vcpkg folder:
  • bootstrap-vcpkg.bat -disableMetrics
  • Ubuntu:~/$ ./bootstrap-vcpkg.sh -disableMetrics
  • vcpkg.exe can be found in the root of the repository

Updating vcpkg

git pull
bootstrap-vcpkg.bat -disableMetrics
vcpkg.exe update
vcpkg.exe upgrade --no-dry-run

Install required packages

vcpkg install libjpeg-turbo:x64-windows-static
vcpkg install zlib:x64-windows-static
vcpkg install libpng:x64-windows-static
vcpkg install giflib:x64-windows-static

The files can then be found here: vcpkg\installed\x64-windows-static\

Clone jpeg-xl and prepare for cmake

git clone --recursive https://gitlab.com/wg1/jpeg-xl
cd jpeg-xl
git checkout 5175d11717f3c48cf506a2c0e0afb070392ae296
#fix build:  add #include <atomic> to the lib/jxl/butteraugli/butteraugli.h 
mkdir build
cd build
cmake ..
  • Then start CMAKE GUI
  • Configure "Where is the source code:" point to the cloned git folder jpeg-xl\
  • Configure "Where to build the binaries:" point to jpeg-xl\build

Static

For a static build change all /Md flags to /MT or /MTd

//Flags used by the CXX compiler during DEBUG builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=/MTd /Zi /Ob0 /Od /RTC1

//Flags used by the CXX compiler during MINSIZEREL builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MT /O1 /Ob1 /DNDEBUG

//Flags used by the CXX compiler during RELEASE builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=/MT /O2 /Ob2 /DNDEBUG

//Flags used by the CXX compiler during RELWITHDEBINFO builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MT /Zi /O2 /Ob1 /DNDEBUG


//Flags used by the C compiler during DEBUG builds.
CMAKE_C_FLAGS_DEBUG:STRING=/MTd /Zi /Ob0 /Od /RTC1

//Flags used by the C compiler during MINSIZEREL builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=/MT /O1 /Ob1 /DNDEBUG

//Flags used by the C compiler during RELEASE builds.
CMAKE_C_FLAGS_RELEASE:STRING=/MT /O2 /Ob2 /DNDEBUG

//Flags used by the C compiler during RELWITHDEBINFO builds.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MT /Zi /O2 /Ob1 /DNDEBUG

Lib Path

  • Configure all Lib paths to where vcpkg installed them, examples:
...
//Path to a file.
GIF_INCLUDE_DIR:PATH=C:\vcpkg\installed\x64-windows-static\include

//Path to a library.
GIF_LIBRARY:FILEPATH=C:\vcpkg\installed\x64-windows-static\lib\gif.lib

...
//Path to a library.
PNG_LIBRARY_DEBUG:FILEPATH=C:\vcpkg\installed\x64-windows-static\debug\lib\libpng16d.lib

//Path to a library.
PNG_LIBRARY_RELEASE:FILEPATH=C:\vcpkg\installed\x64-windows-static\lib\libpng16.lib

//Path to a file.
PNG_PNG_INCLUDE_DIR:PATH=C:\vcpkg\installed\x64-windows-static\include
...

Final steps

in CMAKE GUI press

  • Configure
  • Generate
  • Open in Visual Studio

In Visual Studio:

  • Build

Workaround

If build fails it might help to switch "Platform Toolset" to "LLVM (clang-cl)"

⚠️ **GitHub.com Fallback** ⚠️