Boost.Locale示例不在VS2010中运行

时间:2015-03-21 17:50:13

标签: c++ visual-studio-2010 boost

我一直在努力学习Boost.Locale模块。考虑this示例。代码被成功编译但是当我尝试运行它时,它会给出错误

Unhandled exception at 0x74d34b32 in LearningCPP.exe: Microsoft C++ exception: std::bad_cast at memory location 0x00a6fa48..

我也附上了程序的堆栈跟踪。这是:

    KernelBase.dll!74d34b32()   
    [Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
    KernelBase.dll!74d34b32()   
>   msvcr100d.dll!_nh_malloc_dbg(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine)  Line 302 + 0x1d bytes  C++
    msvcr100d.dll!malloc(unsigned int nSize)  Line 56 + 0x15 bytes  C++
    LearningCPP.exe!std::use_facet<boost::locale::converter<char> >(const std::locale & _Loc)  Line 526 C++
    LearningCPP.exe!boost::locale::to_upper<char>(const char * str, const std::locale & loc)  Line 225 + 0x9 bytes  C++
    LearningCPP.exe!main()  Line 170 + 0xc4 bytes   C++
    LearningCPP.exe!__tmainCRTStartup()  Line 555 + 0x19 bytes  C
    LearningCPP.exe!mainCRTStartup()  Line 371  C
    kernel32.dll!75268543()     
    ntdll.dll!776bac69()    
    ntdll.dll!776bac3c()    

Boost.Locale中使用Visual Studio 2010时是否有人遇到此问题?如果是这样,我该如何解决这个问题?

PS:我在Visual Studio的Use Unicode Character Set选项下使用了选项Character Set。我相信这些库也是正确链接的。

1 个答案:

答案 0 :(得分:0)

对于可能面临同样问题的其他人,我找到了解决方案。该this示例针对calendar.cppcollate.cpp以及来自此link的`conversions.cpp'运行时,该程序仍然出现错误。

解决方案是在BOOST_ALL_DYN_LINK下的预处理器中添加Configuration Properties \ C/C++ \ Preprocessor。该程序之后能够运行。

PS:在链接器中我添加了boost_locale-vc100-mt-gd-1_55.lib