fmt icon indicating copy to clipboard operation
fmt copied to clipboard

fmt::printf("%.*f\n", 15, pi) makes linking fails unless linking against static lib or FMT_HEADER_ONLY defined.

Open denchat opened this issue 3 years ago • 2 comments

Without -DFMT_HEADER_ONLY , this statement

fmt::printf("%.*f\n", 15, pi);

makes the linking fails in both clang v14 and gcc v12 [LIVE]
In clang-cl v14, lld-link fails as below.

lld-link: error: void __cdecl fmt::v9::vprint(class fmt::v9::basic_string_view<char>, class fmt::v9::basic_format_args<class fmt::v9::basic_format_context<class fmt::v9::appender, char>>) was replaced
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)

In clang-cl v14, removing -DFMT_SHARED solves this.
It looks like dynamic precision fmt::printf causes problems on dynamic lib linking.

denchat avatar Sep 03 '22 07:09 denchat

Closing per email comment:

Now the current master 192859c doesn't have this issue. However the issue still shows on compiler explorer as link above. You may close this. Thank you.

vitaut avatar Sep 13 '22 16:09 vitaut

I'm sorry that I didn't clearify the deleted comment. I've mistaken that with static linking.

The issue is still standing.

denchat avatar Sep 14 '22 07:09 denchat

Both clang 14 and gcc 12 work in https://compiler-explorer.com/z/MEn4MPq7a. Not sure what clang-cl error means but it might be due to incompatible build settings. Closing as this doesn't look actionable from our side but if you have any workarounds, a PR would be welcome.

vitaut avatar Nov 24 '22 15:11 vitaut