{fmt} How to install and use fmtlib in Visual Studio?

Once you have downloaded and extracted the fmtlib, Open Visual Studio and create new project New Project -> Console App replace the application file where main method is present with below code.

First line (#define FMT_HEADER_ONLY) is mandatory, which tells compiler to compile fmt header file also.

#define FMT_HEADER_ONLY
#include <iostream>
#include <fmt/color.h>
int main()
{
    std::cout << "Hello World!\n";
    fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
        "Elapsed time: {0:.2f} seconds", 1.23);
}

Go to Properties of project Properties, and click on dropdown of Include Directories as shown in screenshot.

Click on New Line folder Folder Icon and click on line to edit and browse folder path of include directory (C:\Users\username\Downloads\fmt-8.1.0\fmt-8.1.0\include)Browse till include directory of fmt lib.

Cross check the path is added Confirm.

Now build the Project and Execute code. Colorful Text Output

Happy Coding!


I believe fmtlib is header only. You can just add the unzipped folder to your includes.