我在 Embarcadero Berlin 10.1 中创建了一个简单的控制台应用程序,选择了 32 位 clang 编译器,并从boost 文档中的此处复制了一些代码。
这是完整的代码
#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 提供的提升吗?)
有人有建议吗?