简体   繁体   中英

unresolved external using fmt::format to return std::wstring

I am using fmt 7.1.3 with Visual Studio 2019.

I take the fmt src files and make a static lib.

When I link this lib into an exe project that does:

std::wstring out = fmt::format(L"Answer {}", 42);

It compiles but fails with a linker error:

unresolved external symbol "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl fmt::v7::detail::vformat<wchar_t,0>(class fmt::v7::basic_string_view<wchar_t>,class fmt::v7::basic_format_args<class fmt::v7::basic_format_context<class fmt::v7::detail::buffer_appender<wchar_t>,wchar_t> >)" (??$vformat@_W$0A@@detail@v7@fmt@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$basic_string_view@_W@12@V?$basic_format_args@V?$basic_format_context@V?$buffer_appender@_W@detail@v7@fmt@@_W@v7@fmt@@@12@@Z) referenced in function "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl fmt::v7::format<wchar_t [10],int,wchar_t>(wchar_t const (&)[10],int &&)"

The same static lib configuration works fine if I use the src from fmt-6.2.1.

Thanks for your help.

Make sure to include fmt/format.h where this function is defined. Quoting the docs :

fmt/format.h : the full format API providing compile-time format string checks, wide string, output iterator and user-defined type support

Here is a working example on godbolt .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM