linux fmt 打印输出(c++)

fmt 安装和编译:

git clone  https://github.com/fmtlib/fmt.git
cd fmt 
cmake .
make

等编译完成后将 fmt 库直接添加到工程文件夹里面
在这里插入图片描述
将 fmt 库添加到工程文件里面:CMake

add_subdirectory(fmt)
list(APPEND fmt/include)
target_link_libraries(classgo PRIVATE fmt::fmt)

然后编写工程编译输出:

#include <iostream>
#include "fmt/include/fmt/format.h"
#include "fmt/include/fmt/color.h"
using namespace std;
int main()
{
    fmt::print(fg(fmt::color::yellow),"hello format {}\n",0x1b);

}

在这里插入图片描述


使用CMakeLists.txt 也可以使用

cmake_minimum_required(VERSION 3.1...3.18)

project(fmt-test)

find_package(FMT REQUIRED)

add_executable(fmt_test main.cpp)
target_link_libraries(fmt_test fmt::fmt)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值