I am trying to install {fmt} and I have downloaded the zip folder and extracted it, what do I do next to use it in my Visual Studio 2022 project? Because it's my first time installing an external library. Im using windows 10.
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!