On any GCC version (12/13/14), I cannot compile spdlog. I'm using FreeBSD 12 (x86) and I tried compile simple code, but:
spdlog/fmt/bundled/format.h: In instantiation of 'constexpr int fmt::v9::detail::format_float(Float, int, float_specs, buffer&) [with Float = long double]':
spdlog/fmt/bundled/format.h:3230:25: required from 'constexpr OutputIt fmt::v9::detail::write(OutputIt, T, fmt::v9::basic_format_specs<Char>, locale_ref) [with Char = char; OutputIt = fmt::v9::appender; T = long double; typename std::enable_if<std::integral_constant<bool, (std::is_floating_point<T>::value || std::is_same<T, __float128>::value)>::value, int>::type = 0]'
spdlog/fmt/bundled/format.h:3394:25: required from 'constexpr fmt::v9::detail::arg_formatter<Char>::iterator fmt::v9::detail::arg_formatter<Char>::operator()(T) [with T = long double; Char = char; iterator = fmt::v9::appender]'
spdlog/fmt/bundled/core.h:1649:15: required from 'constexpr decltype (vis(0)) fmt::v9::visit_format_arg(Visitor&&, const basic_format_arg<Context>&) [with Visitor = detail::arg_formatter&; Context = basic_format_context<appender, char>; decltype (vis(0)) = appender]'
spdlog/fmt/bundled/format.h:4132:42: required from 'const Char* fmt::v9::detail::vformat_to(buffer<T>&, fmt::v9::basic_string_view<Char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<typename std::conditional<std::is_same<typename fmt::v9::type_identity<T>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<buffer<typename fmt::v9::type_identity<T>::type> > >::type, typename fmt::v9::type_identity<T>::type> >, locale_ref)::format_handler::on_format_specs(int, const Char*, const Char*) [with Char = char]'
spdlog/fmt/bundled/format.h:4135:3: required from 'void fmt::v9::detail::vformat_to(buffer<T>&, fmt::v9::basic_string_view<Char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<typename std::conditional<std::is_same<typename fmt::v9::type_identity<T>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<buffer<typename fmt::v9::type_identity<T>::type> > >::type, typename fmt::v9::type_identity<T>::type> >, locale_ref) [with Char = char; typename std::conditional<std::is_same<typename fmt::v9::type_identity<T>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<buffer<typename fmt::v9::type_identity<T>::type> > >::type = fmt::v9::appender; typename fmt::v9::type_identity<T>::type = char]'
spdlog/fmt/bundled/format-inl.h:1472:21: required from here
spdlog/fmt/bundled/format.h:3122:20: error: invalid use of incomplete type 'struct fmt::v9::detail::dragonbox::float_info<long double, void>'
3122 | const auto f = basic_fp(converted_value);
spdlog/fmt/bundled/format.h:1289:54: note: declaration of 'struct fmt::v9::detail::dragonbox::float_info<long double, void>'
1289 | template <typename T, typename Enable = void> struct float_info;
When I switch compiler to llvm (17), everything compiles well (on Windows also).
CXX_STANDARD 20
spdlog v1.x branch/1.12.0
This is fmt library issue and already fixed fmtlib/fmt#3137.
Use bug fixed version (fmt v10.0.0 or avobe).
Jul 21
'23 13:07
tt4g
Thank you, but - why spdlog doesn't have fixed version?
This is because the API is broken because fmt 10 removed the feature to use std::ostream& operator<<(std::ostream&, const T&) instead if fmt::formatter<T> is not defined.
See #2805, fmtlib/fmt#3318 and fmtlib/fmt#2919
However, you can use latest fmt with the CMake variable SPDLOG_FMT_EXTERNAL.
https://github.com/gabime/spdlog/blob/d8d23a660601a406a1e1aa07380b5b1c5781c190/CMakeLists.txt#L91-L92
Jul 21
'23 14:07
tt4g
In my build process I set it up like this to use a non-bundled version of fmt and build spdlog with fetchContent, leaving this here in case its useful to anyone:
# fmt (dependency of spdlog)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG master
)
FetchContent_MakeAvailable(fmt)
add_custom_command(
TARGET IrredenEngineProfiling
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${fmt_BINARY_DIR}/bin/libfmtd.dll
${PROJECT_BINARY_DIR}/libfmtd.dll
)
# spdlog
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.12.0
)
option(
IR_SPDLOG_FMT_EXTERNAL
"Use external fmt library instead of bundled"
ON
)
FetchContent_GetProperties(spdlog)
if(NOT spdlog_POPULATED)
FetchContent_Populate(spdlog)
set(SPDLOG_FMT_EXTERNAL ${IR_SPDLOG_FMT_EXTERNAL})
endif()
add_subdirectory(
${spdlog_SOURCE_DIR}
${spdlog_BINARY_DIR}
)
target_link_libraries(IrredenEngineProfiling PUBLIC spdlog)
target_include_directories(IrredenEngineProfiling PUBLIC
${spdlog_SOURCE_DIR}/include
)
add_custom_command(
TARGET IrredenEngineProfiling
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${spdlog_BINARY_DIR}/libspdlogd.dll
${PROJECT_BINARY_DIR}/libspdlogd.dll
)