Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol: char fmt::v7::detail::thousands_sep_impl<char>(fmt::v7::detail::locale_ref) #2142

Closed
NobodyXu opened this issue Feb 21, 2021 · 6 comments

Comments

@NobodyXu
Copy link
Contributor

NobodyXu commented Feb 21, 2021

I am using fmt-7.1.3 in my own project swaystatus, however after I define FMT_STATIC_THOUSANDS_SEPARATOR to ',',
ld.lld with lto enabled failed:

ld.lld: error: undefined symbol: char fmt::v7::detail::thousands_sep_impl<char>(fmt::v7::detail::loca
le_ref)
>>> referenced by ld-temp.o
>>>               lto.tmp:(void fmt::v7::detail::handle_int_type_spec<fmt::v7::detail::int_writer<fmt
::v7::detail::buffer_appender<char>, char, unsigned long>&>(char, fmt::v7::detail::int_writer<fmt::v7
::detail::buffer_appender<char>, char, unsigned long>&))
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried define FMT_STATIC_THOUSANDS_SEPARATOR to ',' in every file, but it doesn't solve my problem.

@vitaut
Copy link
Contributor

vitaut commented Feb 21, 2021

Fixed one related issue in e8eff3b but note that you have to compile {fmt} with FMT_STATIC_THOUSANDS_SEPARATOR too, not just your code.

@vitaut vitaut closed this as completed Feb 21, 2021
@NobodyXu
Copy link
Contributor Author

@vitaut Thank you.

I uses this library in FMT_HEADER_ONLYmode, so it should be fine to only define FMT_STATIC_THOUSANDS_SEPARATOR in the files include fmt, right?

@NobodyXu
Copy link
Contributor Author

@vitaut Unfortunately, e8eff3b doesn't work for me.

I am having more errors:

ld.lld: error: undefined symbol: fmt::v7::format_error::~format_error()
>>> referenced by ld-temp.o
>>>               lto.tmp:(fmt::v7::detail::specs_setter<char>::on_fill(fmt::v7::basic_string_view<cha
r>))
>>> referenced by ld-temp.o
>>>               lto.tmp:(fmt::v7::formatter<swaystatus::mem_size_t, char, void>::parse(fmt::v7::basi
c_format_parse_context<char, fmt::v7::detail::error_handler>&))
>>> referenced by ld-temp.o
>>>               lto.tmp:(fmt::v7::formatter<swaystatus::mem_size_t, char, void>::parse(fmt::v7::basi
c_format_parse_context<char, fmt::v7::detail::error_handler>&))
>>> referenced 5 more times

ld.lld: error: undefined symbol: char fmt::v7::detail::thousands_sep_impl<char>(fmt::v7::detail::local
e_ref)
>>> referenced by ld-temp.o
>>>               lto.tmp:(void fmt::v7::detail::handle_int_type_spec<fmt::v7::detail::int_writer<fmt:
:v7::detail::buffer_appender<char>, char, unsigned long>&>(char, fmt::v7::detail::int_writer<fmt::v7::
detail::buffer_appender<char>, char, unsigned long>&))
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

and I was also forced to work around formatter not found error by wrapping NMIPConfig* in a class and specialize fmt::format for the wrapper instead of the NMIPConfig*.

@NobodyXu
Copy link
Contributor Author

@vitaut I have found a solution to it:

I have to #define FMT_HEADER_ONLY in every translation unit that #includes <fmt/format.h>, not just the printer.cc.

But then, the compiled binary seems to be 3K larger.

@vitaut
Copy link
Contributor

vitaut commented Feb 22, 2021

it should be fine to only define FMT_STATIC_THOUSANDS_SEPARATOR in the files include fmt, right?

Yes but as you already found out it should be consistently defined everywhere.

@NobodyXu
Copy link
Contributor Author

Thank you very much for taking your time to solve my problem.

Everything works fine right now and I’ve able to striped away 21K from the executable built.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants