[Boost-bugs] [Boost C++ Libraries] #12417: Linking dynamically to boost::locale::info class on Windows fails when auto-linking is diasbled

Subject: [Boost-bugs] [Boost C++ Libraries] #12417: Linking dynamically to boost::locale::info class on Windows fails when auto-linking is diasbled
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-08-29 07:07:48


#12417: Linking dynamically to boost::locale::info class on Windows fails when
auto-linking is diasbled
------------------------------+---------------------
 Reporter: anonymous | Owner: artyom
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: locale
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------
 There appears to be a name-mangling issue in boost::locale::info related
 to a public static member variable of type std::locale::id, only when
 linking to the DLL on Windows. When using auto-linking, there is no
 problem.

 == Setup ==
 Boost 1.61 (tested on both pre-built and from-source libraries), Windows
 10 x64, MSVC 2015 (cl 19.00.24213.1), using x64 compiler.

 == Code ==

 bugtest.cc

 {{{
 #include <boost/locale.hpp>
 #include <iostream>

 int main()
 {
 std::locale::global(boost::locale::generator().generate("en_US.UTF-8"));
     std::cout << std::use_facet<boost::locale::info>(std::locale()).name()
 << std::endl;
 }
 }}}

 == Compiler Command ==
 {{{
 cl.exe
 -IC:\Boost\include\boost-1_61
 -DBOOST_ALL_NO_LIB
 -EHsc
 -O2
 bugtest.cc
 -link
 -libpath:c:\Boost\lib
 boost_locale-vc140-mt-1_61.lib
 }}}

 == Linker Failure ==

 bugtest.obj : error LNK2019: unresolved external symbol "public: static
 class std::locale::id boost::locale::info::id"
 (?id_at_info@locale_at_boost@@2V02std@@A) referenced in function "class
 boost::locale::info const & __cdecl std::use_facet<class
 boost::locale::info>(class std::locale const &)"
 (??$use_facet_at_Vinfo@locale_at_boost@@@std@@YAAEBVinfo_at_locale@boost@@AEBV20@@Z)
 bugtest.exe : fatal error LNK1120: 1 unresolved externals

 == Workaround ==

 Force dllimport attribute

 {{{
 cl.exe
 -IC:\Boost\include\boost-1_61
 -DBOOST_LOCALE_DECL=__declspec(dllimport)
 -DBOOST_ALL_NO_LIB
 -EHsc
 -O2
 bugtest.cc
 -link
 -libpath:c:\Boost\lib
 boost_locale-vc140-mt-1_61.lib
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12417>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC