将boost :: locale与Embarcadero Berlin 10.1

时间:2016-08-05 07:31:50

标签: c++ boost linker c++builder c++builder-10.1-berlin

我在Embarcadero Berlin 10.1中创建了一个简单的控制台应用程序,选择了32位clang编译器,并复制了here in the boost docs的一些代码。

这是完整的代码

#pragma hdrstop
#pragma argsused

#ifdef _WIN32
#include <tchar.h>
#else
  typedef char _TCHAR;
  #define _tmain main
#endif

#include <stdio.h>

#include <boost/locale.hpp>

int _tmain(int argc, _TCHAR* argv[]) 
{
    using namespace boost::locale;
    using namespace std;
    generator gen;
    locale loc=gen("");
    // Create system default locale

    locale::global(loc);
    // Make it system global

    cout.imbue(loc);
    // Set as default locale for output

    cout <<format("Today {1,date} at {1,time} we had run our first localization example") % time(0)
      <<endl;

    cout<<"This is how we show numbers in this locale "<<as::number << 103.34 <<endl;
    cout<<"This is how we show currency in this locale "<<as::currency << 103.34 <<endl;
    cout<<"This is typical date in the locale "<<as::date << std::time(0) <<endl;
    cout<<"This is typical time in the locale "<<as::time << std::time(0) <<endl;
    cout<<"This is upper case "<<to_upper("Hello World!")<<endl;
    cout<<"This is lower case "<<to_lower("Hello World!")<<endl;
    cout<<"This is title case "<<to_title("Hello World!")<<endl;
    cout<<"This is fold case "<<fold_case("Hello World!")<<endl;

    return 0;
}

但是我收到一些链接器错误:

[ilink32 Error] Error: Unresolved external 'boost::system::generic_category()' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\18.0\LIB\WIN32C\RELEASE\LIBBOOST_LOCALE-BCB32C-MT-SD-1_55.LIB|generator
[ilink32 Error] Error: Unresolved external 'boost::system::system_category()' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\18.0\LIB\WIN32C\RELEASE\LIBBOOST_LOCALE-BCB32C-MT-SD-1_55.LIB|generator
[ilink32 Error] Error: Unresolved external 'boost::locale::impl_win::create_convert(std::locale&, boost::locale::impl_win::winlocale&, unsigned int)' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\18.0\LIB\WIN32C\RELEASE\LIBBOOST_LOCALE-BCB32C-MT-SD-1_55.LIB|win_backend
[ilink32 Error] Error: Unresolved external 'boost::locale::impl_win::create_collate(std::locale&, boost::locale::impl_win::winlocale&, unsigned int)' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\18.0\LIB\WIN32C\RELEASE\LIBBOOST_LOCALE-BCB32C-MT-SD-1_55.LIB|win_backend
[ilink32 Error] Error: Unresolved external 'boost::locale::impl_win::create_formatting(std::locale&, boost::locale::impl_win::winlocale&, unsigned int)' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\18.0\LIB\WIN32C\RELEASE\LIBBOOST_LOCALE-BCB32C-MT-SD-1_55.LIB|win_backend
[ilink32 Error] Error: Unresolved external 'boost::locale::impl_win::create_parsing(std::locale&, boost::locale::impl_win::winlocale&, unsigned int)' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\18.0\LIB\WIN32C\RELEASE\LIBBOOST_LOCALE-BCB32C-MT-SD-1_55.LIB|win_backend

我可以通过手动将libboost_locale-bcb32c-MT-SD-1_55.lib添加到项目中来解决前两个问题,这是我对boost的理解和体验,它不应该真的需要手动链接,但我不介意。然而,最后4个,我根本不确定。它看起来与语言环境后端有关(它不是ICU与Embarcadero提供的提升吗?)

有人有任何建议吗?

1 个答案:

答案 0 :(得分:1)

你的问题非常有趣。所以我创建了一个新项目并将代码复制到其中,确定问题重复了。
在做了一些研究后,我能够克服这个问题的唯一方法是添加collate.cpp和{{1位于converter.cpp的{​​}}和numeric.cpp到我的项目中。 我还必须在$(BDSINCLUDE)\boost_1_55\libs\locale\src\win32函数之前将#pragma link "libboost_system-bcb32c-mt-sd-1_55.lib"添加到我的源代码中。

萨姆