zoukankan      html  css  js  c++  java
  • win8.1系统vs2013中boost 1.55.0的安装

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

    boost_1_55_0oostintrusivedetailhas_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.0VCinvcvars32.bat"编译32位

          "C:Program Files (x86)Microsoft Visual Studio 12.0VCinamd64vcvars64.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=".invc12_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=".invc12_x64" link=static 
    runtime-link=shared threading=multi debug release address-model=64  
    4、添加boostest工程的包含目录和库目录

    包含目录添加  D:oost_1_55_0

    库目录添加    D:oost_1_55_0stagelib

    具体如下图:




    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;
    
    }
    结果:


    Ubuntu中执行:

    1. 设置执行属性: chmod 755 bootstrap.sh

    2.执行(如果已经在当前目录) :    ./bootstrap.sh

    3.bjam





    bjam命令参数分析

    (1)stage/install:

    stage表示只生成库(dll和lib),install还会生成包含头文件的include目录。本人推荐使用stage,因为install生成的这个include目录实际就是boost安装包解压缩后的boost目录(E:SDKoostoost,只比include目录多几个非hpp文件,都很小),所以可以直接使用,而且不同的IDE都可以使用同一套头文件,这样既节省编译时间,也节省硬盘空间。

    (2)toolset:

    指定编译器,可选的如borland、gcc、msvc(VC6)、msvc-9.0(VS2008)等。

    (3)without/with:

    选择不编译/编译哪些库。因为python、mpi等库我都用不着,所以排除之。还有wave、graph、math、regex、test、program_options、serialization、signals这几个库编出的静态lib都非常大,所以不需要的也可以without掉。这可以根据各人需要进行选择,默认是全部编译。但是需要注意,如果选择编译python的话,是需要python语言支持的,应该到python官方主页http://www.python.org/下载安装。

    查看boost包含库的命令是bjam --show-libraries

    (4)stagedir/prefix:

    stage时使用stagedir,install时使用prefix,表示编译生成文件的路径。推荐给不同的IDE指定不同的目录,如VS2008对应的是E:SDKoostinvc9,VC6对应的是E:SDKoostinvc6,否则都生成到一个目录下面,难以管理。如果使用了install参数,那么还将生成头文件目录,vc9对应的就是E:SDKoostinvc9includeoost-1_46oost,vc6类似(光这路径都这样累赘,还是使用stage好)。

    (5)build-dir:

    编译生成的中间文件的路径。这个本人这里没用到,默认就在根目录(E:SDKoost)下,目录名为bin.v2,等编译完成后可将这个目录全部删除(没用了),所以不需要去设置。

    (6)link:

    生成动态链接库/静态链接库。生成动态链接库需使用shared方式,生成静态链接库需使用static方式。一般boost库可能都是以static方式编译,因为最终发布程序带着boost的dll感觉会比较累赘。

    (7)runtime-link:

    动态/静态链接C/C++运行时库。同样有shared和static两种方式,这样runtime-link和link一共可以产生4种组合方式,各人可以根据自己的需要选择编译。

    (8)threading:

    单/多线程编译。一般都写多线程程序,当然要指定multi方式了;如果需要编写单线程程序,那么还需要编译单线程库,可以使用single方式。

    (9)debug/release:

    编译debug/release版本。一般都是程序的debug版本对应库的debug版本,所以两个都编译。

  • 相关阅读:
    html_py
    PHP-FPM详解
    nginx 虚拟主机配置
    正确配置Nginx+PHP
    centos7安装Nginx
    如何让浏览器关闭后session失效
    微擎中消息响应回复 代码流程
    在vue组件库中不能使用v-for
    微信分享前面
    php接受axios数据
  • 原文地址:https://www.cnblogs.com/ggzone/p/10121356.html
Copyright © 2011-2022 走看看