Is it possible to use fmt in a fully header-only mode? I'm trying to use it in a ROOT script (C++ that gets interpreted by Cling) which means I can't use CMake, or even link in extra translation units. The only thing I can do is include header files.
I tried using FMT_HEADER_ONLY, but I get missing symbol errors.
Is it possible to use fmt in a fully header-only mode?
Yes, you need to define FMT_HEADER_ONLY before including any fmt's code.
I tried using FMT_HEADER_ONLY, but I get missing symbol errors.
What exactly errors do you get?
IncrementalExecutor::executeFunction: symbol '_ZN3fmt8internal9BasicDataIvE15POWERS_OF_10_32E' unresolved while linking [cling interface function]!
You are probably missing the definition of fmt::internal::BasicData<void>::POWERS_OF_10_32
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN3fmt8internal9BasicDataIvE15POWERS_OF_10_64E' unresolved while linking [cling interface function]!
You are probably missing the definition of fmt::internal::BasicData<void>::POWERS_OF_10_64
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN3fmt8internal9BasicDataIvE6DIGITSE' unresolved while linking [cling interface function]!
You are probably missing the definition of fmt::internal::BasicData<void>::DIGITS
Maybe you need to load the corresponding shared library?
I'm not sure how to set a macro in cling, but you can create a wrapper header:
#define FMT_HEADER_ONLY
#include "fmt/format.h"
and use it instead of format.h.
I already do that. Those errors are with FMT_HEADER_ONLY defined.
Looks like some cling issue in handling static member variables in template. You could try using fmt as a dynamic library instead.
Most helpful comment
I'm not sure how to set a macro in cling, but you can create a wrapper header:
and use it instead of
format.h.