导航

win8.1系统vs2013中boost 1.55.0的安装

Posted on 2014-07-16 21:48  ggzone  阅读(180)  评论(0编辑  收藏  举报

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

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

template<class U>
static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
       <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);
替换成以下内容:

#ifdef BOOST_MSVC
     template<class U>
     static decltype(boost::move_detail::declval<Fun>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME()
           , boost_intrusive_has_member_function_callable_with::yes_type())
           Test(Fun*);
#else
     template<class U>
     static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
           <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);
#endif

1、管理员权限cmd中运行:

      "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"编译32位

      "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat"编译64位

2、命令行进入boost所在目录,运行bootstrap.bat(我的64位没有执行步骤一出错)

3、32位编译:

     

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_x86" link=static 
runtime-link=shared threading=multi debug release

     64位编译:

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  
4、添加boostest工程的包含目录和库目录

包含目录添加  D:\boost_1_55_0

库目录添加    D:\boost_1_55_0\stage\lib

具体如下图:




5、测试代码:

#include <boost/lexical_cast.hpp>     

#include <iostream>     

using namespace std;

int main()

{

	using boost::lexical_cast;

	int a = lexical_cast<int>("123");

	double b = lexical_cast<double>("123.0123456789");

	string s0 = lexical_cast<string>(a);

	string s1 = lexical_cast<string>(b);

	cout << "number: " << a << "  " << b << endl;

	cout << "string: " << s0 << "  " << s1 << endl;

	int c = 0;

	try{

		c = lexical_cast<int>("abcd");

	}

	catch (boost::bad_lexical_cast& e){

		cout << e.what() << endl;

	}
	system("pause");
	return 0;

}
结果: