VS2013编译boost1.55库

柔情只为你懂 2021-12-24 13:15 380阅读 0赞
  1. 官网下载最新的Boost库,我的是1.55

2.

在使用vs2013编译boost-1.55.0之前,先要给boost做下修改:

boost_1_55_0\boost\intrusive\detail\has_member_function_callable_with.hpp line:222

  1. template<class U>
  2. static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
  3. <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);

替换成以下内容:

  1. #ifdef BOOST_MSVC
  2. template<class U>
  3. static decltype(boost::move_detail::declval<Fun>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME()
  4. , boost_intrusive_has_member_function_callable_with::yes_type())
  5. Test(Fun*);
  6. #else
  7. template<class U>
  8. static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
  9. <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);
  10. #endif
  1. 编译

64位编译:

  1. 从开始菜单启动Visual Studio 2013的vs2013 x64兼容工具命令行,然后转到boost根文件夹,运行bootstrap.bat生成x64版的bjam.exe。
  2. 运行命令:

bjam.exe stage —toolset=msvc-12.0 —without-graph —without-graph_parallel —without-math —without-mpi —without-serialization

--without-wave —without-test —without-program_options —without-serialization —without-signals

--stagedir=”.\bin\vc12_x64” link=static runtime-link=shared threading=multi debug release address-model=64

  1. 添加boostest工程的包含目录和库目录

272012127552330.jpg

添加库目录

272012535362570.jpg

  1. 测试程序

    新建一个空的Win32 Console Application项目

    include

    include

    include

    int main()
    {

    1. int a = boost::lexical_cast<int>("123");
    2. double b = boost::lexical_cast<double>("123.0123456789");
    3. std::string s0 = boost::lexical_cast<std::string>(a);
    4. std::string s1 = boost::lexical_cast<std::string>(b);
    5. std::cout << "number is: " << a << " " << b << std::endl;
    6. std::cout << "string is: " << s0 << " " << s1 << std::endl;
  1. int c = 0;
  2. try
  3. {
  4. c = boost::lexical_cast<int>("abcd");
  5. }
  6. catch (boost::bad_lexical_cast & e)
  7. {
  8. std::cout << e.what() << std::endl;
  9. return -1;
  10. }
  11. return 0;
  12. }
  1. 运行结果:

number is: 123 123.012
string is: 123 123.0123456789
bad lexical cast: source type value could not be interpreted as target
Press any key to continue . . .

转载于:https://www.cnblogs.com/davidgu/p/4461145.html

发表评论

表情:
评论列表 (有 0 条评论,380人围观)

还没有评论,来说两句吧...

相关阅读