本文仅为参考,请以实际情况为准,
1、准备
下载源码fmt : https://github.com/fmtlib/fmt
没有cmake? 下载地址: https://cmake.org/download/
没有win10 和 VS历史版本? 下载地址: https://msdn.itellyou.cn/
注意: 这里的教程已经将cmake添加到环境变量中。
2、解压
解压下载好的fmt源码 ,打开解压文件夹后,创建文件夹build (用作cmake的输出, 可创建到其他位置)
3、使用cmake生成解决方案
打开 build 目录, 使用命令【cmake ..】生成:对应的解决方案。 输出如下:
C:\fmt-7.0.1\build>cmake ..
-- Building for: Visual Studio 14 2015
-- CMake version: 3.18.0-rc3
-- Selecting Windows SDK version to target Windows 10.0.18363.
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/major/development/tools/vs_install/vs_2015/VC/bin/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Version: 7.0.1
-- Build type: Release
-- CXX_STANDARD: 11
-- Performing Test has_std_11_flag
-- Performing Test has_std_11_flag - Success
-- Performing Test has_std_0x_flag
-- Performing Test has_std_0x_flag - Failed
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS - Success
-- Performing Test FMT_HAS_VARIANT
-- Performing Test FMT_HAS_VARIANT - Failed
-- Required features: cxx_variadic_templates
-- Looking for _strtod_l
-- Looking for _strtod_l - found
-- Target ‘doc‘ disabled (requires doxygen)
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS
-- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS - Failed
-- FMT_PEDANTIC: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: C:/fmt-7.0.1/build
4、打开 build 目录下的 fmt.sln, 找到 fmt项目, 默认为静态库,我这里演示为生成的动态库。
5、选择项目fmt, 右键选择生成,根据需要 debug 和 releas 都需要生成。
6、找打生成的目标文件,
A、需要拷贝 源码文件夹include 下的fmt文件夹,这里 包含了各种fmt需要的接口。
B、找到fmt项目生成的目标文件: fmtd.dll 和 fmtd.lib 。对应的还有release下的 fmt.dll 和 fmt.lib。
还等什么, 赶快创建项目,体验fmt带给你的喜悦 吧。
可参考 : https://www.cnblogs.com/pandamohist/p/13362139.html