Skip to content
Victor Derks edited this page Jan 5, 2022 · 7 revisions

Introduction

The most practical way to use CharLS is to use the source distribution and build it yourself. This ensures that the library matches your C++ compiler and environment. Released versions of CharLS are available as ports in the C++ vcpkg manager.
The next sections will explain how to build CharLS from its Git repository. These sections assume that the reader has a basic understanding how to build C++ software libraries.

General

Required Tools

Git
CharLS is maintained in a Git repository hosted on Github. Released versions can be downloaded as a zip or tar.gz file. Unreleased version can be retrieved as git repository. A git client can be downloaded from http://git-scm.com

CMake
CharLS ships with a CMakeLists.txt files that can be used with CMake. CMake is a cross platform meta build tool that can generate native build scripts. CMake can be downloaded from http://www.cmake.org/

C++ Compiler
To build CharLS 2.x a C++ 14 compatible compiler is required (CharLS 1.x can be build with C++03). If a C++ compiler is installed correctly on your system CMake will be able to find it.

General Build Steps

  1. Clone the CharLS Git repository to your own system.

  2. CMake can be used to build in-source and out-of-source. The recommendation is to build CharLS out-of-source:

  3. To build the “debug” version, use the following steps:

    • cd into the root directory of your cloned charls directory
    • mkdir debug
    • cd debug
    • cmake -DCMAKE_BUILD_TYPE=Debug .. (static library) or
    • cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=On .. (shared library)
    • make (or ninja on Windows)
  4. To build the “release” version, use the following steps:

    • cd into the root directory of your cloned charls directory
    • mkdir release
    • cd release
    • cmake -DCMAKE_BUILD_TYPE=Release .. (static library) or
    • cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On .. (shared library)
    • make (or ninja on Windows)

Note 1: On Windows pass -G ninja to the cmake command line to force the creation of ninja make files. The default on the Windows platform is to generate Visual Studio project files.

Windows (Visual Studio)

CharLS comes also with a Visual Studio 2019\2022 solution. Instead of using CMake, MSBuild or the Visual Studio 2019 IDE can be used to build Charls. Newer versions of Visual Studio can also open directly the CMakeLists.txt build script.

Windows (MinGW)

GCC for Windows (MinGW) can be used to build CharLS, for example:

  • cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -G "MinGW Makefiles" ..
  • make

macOS (Xcode)

The provided CMake CMakeLists.txt build script files can also be used to create a Xcode project file, allowing CharLS to be build inside the Xcode IDE. The following steps will create a Xcode project file and open it in Xcode:
- cd into the root directory of your cloned charls directory
- mkdir build
- cd build
- cmake -G Xcode ..
- open charls.xcodeproj/

Clone this wiki locally