spdlog_setup
spdlog_setup copied to clipboard
Multiply defined symbols linker error when using with compiled spdlog lib
When using spdlog as a compiled library in a project, trying to use spdlog_setup will result in multiply defined symbols linker errors:
spdlog.lib(fmt.cpp.obj) : error LNK2005: "public: virtual __cdecl fmt::v6::format_error::~format_error(void)" (??1format_error@v6@fmt@@UEAA@XZ) already defined in core_application.cpp.obj
This led me to https://github.com/fmtlib/fmt/issues/372#issuecomment-241204047 which in turn led me to look for this in spdlog_setup sources.
In conf_impl.h, changing
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
to
#if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY)
#define FMT_HEADER_ONLY
#endif
seems to correctly not set FMT_HEADER_ONLY and allows linking on windows.