Fmt: undefined reference to `fmt::internal::error_handler::on_error(char const*)'

Created on 28 Mar 2018  路  3Comments  路  Source: fmtlib/fmt

when i use this code, i get a buch of errors

code:

template <typename... Args>
void log(std::string message,
           const Args&... args) {
    fmt::arg_store<fmt::context, Args...> as(args...);
    std::cout << fmt::vformat(message, as);
}

error:

shader.cpp.o: In function `fmt::float_spec_handler<char>::on_error()':
fmt/include/fmt/format.h:2692: undefined reference to `fmt::format_error::~format_error()'
shader.cpp.o: In function `fmt::format_error::format_error(char const*)':
fmt/include/fmt/format.h:326: undefined reference to `vtable for fmt::format_error'
shader.cpp.o: In function `fmt::float_spec_handler<char>::on_error()':
fmt/include/fmt/format.h:2692: undefined reference to `typeinfo for fmt::format_error'
shader.cpp.o: In function `fmt::basic_parse_context<char, fmt::internal::error_handler>::on_error(char const*)':
fmt/include/fmt/core.h:754: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
fmt/include/fmt/core.h:754: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
fmt/include/fmt/core.h:754: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
fmt/include/fmt/core.h:754: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
fmt/include/fmt/core.h:754: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o:fmt/include/fmt/format.h:1551: more undefined references to `fmt::internal::error_handler::on_error(char const*)' follow
shader.cpp.o: In function `void fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::write_double<double>(double, fmt::basic_format_specs<char> const&)':
fmt/include/fmt/format.h:2772: undefined reference to `int fmt::internal::char_traits<char>::format_float<double>(char*, unsigned long, char const*, unsigned int, int, double)'
shader.cpp.o: In function `void fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::write_double<long double>(long double, fmt::basic_format_specs<char> const&)':
fmt/include/fmt/format.h:2772: undefined reference to `int fmt::internal::char_traits<char>::format_float<long double>(char*, unsigned long, char const*, unsigned int, int, long double)'
shader.cpp.o: In function `char* fmt::internal::format_decimal<unsigned long, char, fmt::internal::no_thousands_sep>(char*, unsigned long, unsigned int, fmt::internal::no_thousands_sep)':
fmt/include/fmt/format.h:918: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:934: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:918: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:934: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:918: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
shader.cpp.o:fmt/include/fmt/format.h:934: more undefined references to `fmt::internal::basic_data<void>::DIGITS' follow
shader.cpp.o: In function `fmt::internal::count_digits(unsigned long)':
fmt/include/fmt/format.h:776: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_64'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<unsigned long, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned long)':
fmt/include/fmt/format.h:776: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_64'
shader.cpp.o: In function `char* fmt::internal::format_decimal<unsigned int, char, fmt::internal::no_thousands_sep>(char*, unsigned int, unsigned int, fmt::internal::no_thousands_sep)':
fmt/include/fmt/format.h:918: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:934: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:918: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:934: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
fmt/include/fmt/format.h:918: undefined reference to `fmt::internal::basic_data<void>::DIGITS'
shader.cpp.o:fmt/include/fmt/format.h:934: more undefined references to `fmt::internal::basic_data<void>::DIGITS' follow
shader.cpp.o: In function `fmt::internal::count_digits(unsigned int)':
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
shader.cpp.o: In function `void fmt::internal::check_string_type_spec<char, fmt::internal::error_handler>(char, fmt::internal::error_handler&&)':
fmt/include/fmt/format.h:1258: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `void fmt::internal::check_pointer_type_spec<char, fmt::internal::error_handler>(char, fmt::internal::error_handler&&)':
fmt/include/fmt/format.h:1264: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `void fmt::internal::handle_cstring_type_spec<char, fmt::internal::arg_formatter_base<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::cstring_spec_handler>(char, fmt::internal::arg_formatter_base<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::cstring_spec_handler&&)':
fmt/include/fmt/format.h:1252: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `void fmt::internal::handle_char_specs<char, fmt::internal::arg_formatter_base<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::char_spec_handler>(fmt::basic_format_specs<char> const&, fmt::internal::arg_formatter_base<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::char_spec_handler&&)':
fmt/include/fmt/format.h:1241: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `fmt::format_error::format_error(char const*)':
fmt/include/fmt/format.h:326: undefined reference to `vtable for fmt::format_error'
shader.cpp.o: In function `fmt::internal::arg_formatter_base<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::write(char const*)':
fmt/include/fmt/format.h:1403: undefined reference to `fmt::format_error::~format_error()'
fmt/include/fmt/format.h:1403: undefined reference to `typeinfo for fmt::format_error'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned int)':
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<unsigned int, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned long)':
fmt/include/fmt/format.h:776: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_64'
fmt/include/fmt/format.h:776: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_64'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<unsigned long long, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned long)':
fmt/include/fmt/format.h:776: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_64'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned int)':
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<int, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned long)':
fmt/include/fmt/format.h:776: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_64'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<long long, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned int)':
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<int, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned int)':
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
shader.cpp.o: In function `fmt::basic_writer<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >::int_writer<char, fmt::basic_format_specs<char> >::on_num()':
fmt/include/fmt/format.h:2456: undefined reference to `char fmt::internal::thousands_sep<char>(fmt::locale_provider*)'
shader.cpp.o: In function `fmt::internal::count_digits(unsigned int)':
fmt/include/fmt/format.h:875: undefined reference to `fmt::internal::basic_data<void>::POWERS_OF_10_32'
shader.cpp.o: In function `fmt::internal::id_adapter<fmt::format_handler<fmt::arg_formatter<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >, char, fmt::basic_context<std::back_insert_iterator<fmt::internal::basic_buffer<char> >, char> >&, char>::on_error(char const*)':
fmt/include/fmt/format.h:1992: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `void fmt::internal::parse_format_string<fmt::internal::null_terminating_iterator<char>, fmt::format_handler<fmt::arg_formatter<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >, char, fmt::basic_context<std::back_insert_iterator<fmt::internal::basic_buffer<char> >, char> >&>(fmt::internal::null_terminating_iterator<char>, fmt::format_handler<fmt::arg_formatter<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >, char, fmt::basic_context<std::back_insert_iterator<fmt::internal::basic_buffer<char> >, char> >&)':
fmt/include/fmt/format.h:2027: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `fmt::basic_parse_context<char, fmt::internal::error_handler>::on_error(char const*)':
fmt/include/fmt/core.h:754: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `fmt::format_handler<fmt::arg_formatter<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >, char, fmt::basic_context<std::back_insert_iterator<fmt::internal::basic_buffer<char> >, char> >::on_format_specs(fmt::internal::null_terminating_iterator<char>)':
fmt/include/fmt/format.h:3206: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o: In function `void fmt::internal::parse_format_string<fmt::internal::null_terminating_iterator<char>, fmt::format_handler<fmt::arg_formatter<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >, char, fmt::basic_context<std::back_insert_iterator<fmt::internal::basic_buffer<char> >, char> >&>(fmt::internal::null_terminating_iterator<char>, fmt::format_handler<fmt::arg_formatter<fmt::back_insert_range<fmt::internal::basic_buffer<char> > >, char, fmt::basic_context<std::back_insert_iterator<fmt::internal::basic_buffer<char> >, char> >&)':
fmt/include/fmt/format.h:2023: undefined reference to `fmt::internal::error_handler::on_error(char const*)'
shader.cpp.o:fmt/include/fmt/core.h:754: more undefined references to `fmt::internal::error_handler::on_error(char const*)' follow
collect2: error: ld returned 1 exit status

Most helpful comment

There is a header-only mode which is enabled by defining macro FMT_HEADER_ONLY. See http://fmtlib.net/latest/usage.html#header-only-usage-with-cmake.

All 3 comments

Do you link with the fmt library (libfmt.a)?

bother, it was that, i thought it was header only

There is a header-only mode which is enabled by defining macro FMT_HEADER_ONLY. See http://fmtlib.net/latest/usage.html#header-only-usage-with-cmake.

Was this page helpful?
0 / 5 - 0 ratings