gabime / spdlog

Fast C++ logging library.
Other
24.39k stars 4.55k forks source link

fmt conflict with another lib (VRS) #3163

Closed biggiantpigeon closed 2 months ago

biggiantpigeon commented 2 months ago

In my own project A, I'm using VRS and my own project B, and in B I use spdlog. Vrs and spdlog both use fmt from https://github.com/fmtlib/fmt, but their implementations are different.

My problem is, I can compile pass project B, but when I compile project A, the fmt in spdlog and vrs seems to have a confict and cannot compile pass. I checked both of VRS and spdlog, they directly put fmt in source code but not add it from cmake. I'm not sure what to do, can I get some suggestions? I saw some options about fmt in cmake options, but didn't find any documentation.

BTW, this only happens when I include spdlog.h in header files of B, but ok if I include spdlog in cpp files.

Heres the error (sorry about the Chinese, T_T, hope that's not a trouble):

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(16,12): error C2143: 语法错误: 缺少“;”(在“enum [tag]”的前面) [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]
  (编译源文件“../src/service/slam_algo.cpp”)

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(16,29): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]  (编译源文件“../src/service/slam_algo.cpp”)

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(630,1): error C2143: 语法错误: 缺少“;”(在“}”的前面) [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]
  (编译源文件“../src/service/slam_algo.cpp”)

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(16,29): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]  (编译源文件“../src/service/slam_algo.cpp”)
  (编译源文件“../src/service/slam_algo.cpp”)
  (编译源文件“../src/service/slam_algo.cpp”)

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(16,29): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]  (编译源文件“../src/service/slam_algo.cpp”)

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(630,1): error C2143: 语法错误: 缺少“;”(在“}”的前面) [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]
  (编译源文件“../src/service/slam_algo.cpp”)

C:\Users\...\amd64-windows\vrs\vrs\include\fmt\color.h(630,1): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int [E:\git_repo\tracking-service-interface\_build\trackingservice_lib.vcxproj]
tt4g commented 2 months ago

fmt is bundled in part of spdlog source code.

if you should not use bundled fmt, build spdlog with CMake variable SPDLOG_FMT_EXTERNAL defined, Then fmt bundled in spdlog will be excluded from the build.

https://github.com/gabime/spdlog/blob/a3a0c9d66386962fcaf0178fcae03ac77c1e0257/CMakeLists.txt#L91-L92