zoukankan      html  css  js  c++  java
  • 如何编译&使用boost库?

    

    1. 编译

    1.1. 下载地址:http://www.boost.org/
    1.2. VS2005编译boost_1_55_0
    1.2.1. 使用vs2005的命令行执行:...oost_1_55_0ootstrap.bat
    1.2.2. 编译动态库
    bjam install stage --toolset=msvc-8.0 --stagedir="C:Boostoost_vc_80" link=shared runtime-link=shared threading=multi debug release 

    1.2.3. 编译静态库

    bjam install stage --toolset=msvc-8.0 --stagedir="D:Boostoost_vc_80" link=static runtime-link=static threading=multi debug release  

    各种参数详解:
    stage:表示只生成库(dll和lib)
    install:还会生出包含的头文件
    --toolset=msvc-8.0:指定编译器版本,8.0为vs2005,其他VS类推。
    --stagedir:指定编译后存放的目录
    link:生成动态库/静态库。动态库(shared),静态库(static)
    runtime-link:动态/静态C/C++运行时库,同样有shared和static两种组合方式。这样共有4种组合方式,个人根据自己需要选择。
    threading:单/多线程,一般都是多线程程序,当然multi了。
    debug/release:编译版本,一般2个都需要。

    2. 使用

    使用静态库:
    1. //#define BOOST_ALL_DYN_LINK  
    2. #include <boost/bind.hpp>  
    3. #include <boost/asio.hpp>  
    4. #include <boost/thread/thread.hpp>  
    5. #include <boost/thread/mutex.hpp>  
    6. #include <boost/thread/condition.hpp>  
    使用静态库连接时,仅需要包含的lib为:
    debug版:libboost_system-vc80-mt-gd-1_55.lib等一系列包含gd的库。
    release版本:libboost_system-vc80-mt-1_55.lib等一系列不包含gd的库。

    使用动态库链接:
    1. #define BOOST_ALL_DYN_LINK  
    2. #include <boost/bind.hpp>  
    3. #include <boost/asio.hpp>  
    4. #include <boost/thread/thread.hpp>  
    5. #include <boost/thread/mutex.hpp>  
    6. #include <boost/thread/condition.hpp>  
    使用动态库链接时,仅需要包含的lib为:
    debug版:boost_system-vc80-mt-gd-1_55.lib,同时在生成的exe加入boost_system-vc80-mt-gd-1_55.dll
    release版:boost_system-vc80-mt-1_55.lib,同时在生产的exe路径下加入boost_system-vc80-mt-1_55.dll

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 2015/3/26第2次编辑
    当你将
    bjam install stage --toolset=msvc-8.0 --stagedir="C:Boostoost_vc_80" link=shared runtime-link=shared threading=multi debug release 
    里面的"install"和"-stagedir="C:Boostoost_vc_80"去掉的时候,会在当前夹子下面默认生成一个stage文件夹存放生成的库。

    参考:
    1. http://blog.csdn.net/liukang0618/article/details/9149881
    2. http://chenrongya.blog.163.com/blog/static/874741962010102041157963/
    3. http://blog.csdn.net/alex_my/article/details/17630685
  • 相关阅读:
    Servlet开发
    HTML实现页面自动跳转的五种方法
    AVAYA话机管理
    AVAYA路由
    报关相关知识
    基本杆法
    AVAYA初始配置
    加塞和瞄准
    基本杆法图解
    AVAYA拨号计划
  • 原文地址:https://www.cnblogs.com/inory/p/5468701.html
Copyright © 2011-2022 走看看