ubuntu or MacOS 源码安装 fmt fmtlib

1,前情

提醒这个源代码需要从release中下载 打包好的,而直接用git clone下载不了,可能github上的这个git clone的链接仅仅是给fmt lib的开发者使用的吧;

下载fmtlib的release源代码
u下载fmtlib的release源代码

2,解压编译安装

复制代码
401  tar zxf fmt-10.1.1.tar
  402  ls
  403  cd fmt-10.1.1
  404  ls
  405  mkdir build
  406  cd build
  407  ls
  408  cmake ..
  409  ls
  410  make -j
  411  cd bin
  412  ls
  413  ./core-test
  414  cd ..
  415  sudo make install

由于是在mac上下载的,所以下载下来的压缩包后缀为.tar;

解压命令倒是没变

效果:

3,示例

hello_fmt.cpp:

复制代码
#include <fmt/format.h>
#include <iostream>

int main()
{
        std::string first_string = fmt::format("{0} the fmt {1} {2}", "Hello", "world!", 123);
        std::cout << first_string <<std::endl;

        return 0;
}

运行效果:

编译命令:

g++ hello_fmt.cpp -lfmt -std=c++11

注意代码库使用了 c++11标准编写

相关推荐
Johny_Zhao17 小时前
centos7安装部署openclaw
linux·人工智能·信息安全·云计算·yum源·系统运维·openclaw
haibindev17 小时前
在 Windows+WSL2 上部署 OpenClaw AI员工的实践与踩坑
linux·wsl2·openclaw
vi_h1 天前
在 macOS 上通过 Docker 安装并运行 Ollama(详细可执行教程)
macos·docker·ollama
樱木Plus2 天前
深拷贝(Deep Copy)和浅拷贝(Shallow Copy)
c++
0xDevNull2 天前
Linux切换JDK版本详细教程
linux
进击的丸子2 天前
虹软人脸服务器版SDK(Linux/ARM Pro)多线程调用及性能优化
linux·数据库·后端
Johny_Zhao3 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
blasit4 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_5 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++