To use the {fmt} library, add fmt/core.h, fmt/format.h, fmt/format-inl.h, src/ and optionally other headers from a release archive or the Git repository to your project. Alternatively, you can build the library with CMake.

Building the Library

The included CMake build script can be used to build the fmt library on a wide range of platforms. CMake is freely available for download from

CMake works by generating native makefiles or project files that can be used in the compiler environment of your choice. The typical workflow starts with:

mkdir build          # Create a directory to hold the build output.
cd build
cmake ..  # Generate native build scripts.

where <path/to/fmt> is a path to the fmt repository.

If you are on a *nix system, you should now see a Makefile in the current directory. Now you can build the library by running make.

Once the library has been built you can invoke make test to run the tests.

You can control generation of the make test target with the FMT_TEST CMake option. This can be useful if you include fmt as a subdirectory in your project but don’t want to add fmt’s tests to your test target.

If you use Windows and have Visual Studio installed, a FMT.sln file and several .vcproj files will be created. You can then build them using Visual Studio or msbuild.

On Mac OS X with Xcode installed, an .xcodeproj file will be generated.

To build a shared library set the BUILD_SHARED_LIBS CMake variable to TRUE:


Installing the Library

After building the library you can install it on a Unix-like system by running sudo make install.

Usage with CMake

You can add the fmt library directory into your project and include it in your CMakeLists.txt file:



add_subdirectory(fmt EXCLUDE_FROM_ALL)

to exclude it from make, make all, or cmake --build ..

You can detect and use an installed version of {fmt} as follows:

target_link_libraries(<your-target> fmt::fmt)

Setting up your target to use a header-only version of fmt is equally easy:

target_link_libraries(<your-target> PRIVATE fmt::fmt-header-only)

Building the Documentation

To build the documentation you need the following software installed on your system:

  • Python with pip and virtualenv

  • Doxygen

  • Less with less-plugin-clean-css. Ubuntu doesn’t package the clean-css plugin so you should use npm instead of apt to install both less and the plugin:

    sudo npm install -g less less-plugin-clean-css.

First generate makefiles or project files using CMake as described in the previous section. Then compile the doc target/project, for example:

make doc

This will generate the HTML documentation in doc/html.


fmt can be installed on Linux, macOS and Windows with Conda, using its conda-forge package, as follows:

conda install -c conda-forge fmt


You can download and install fmt using the vcpkg dependency manager:

git clone
cd vcpkg
./vcpkg integrate install
./vcpkg install fmt

The fmt port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Android NDK

fmt provides file that can be used to build the library with Android NDK. For an example of using fmt with Android NDK, see the android-ndk-example repository.


fmt can be installed on OS X using Homebrew:

brew install fmt