VS2010 + STLport + Boost 的编译使用

Visual Studio 2010 下编译使用 STLport 库和 Boost 库,需要做一些小处理,特记录一下:

首先,下载、解压、安装,这个就不详细说明了,可以看下面的参考或者搜索一下就有很多了。

然后,修改 “stlport\stl\_cstdlib.h” 文件,在 158 行附近找到下面的一行代码:

[cpp]  view plain copy
  1. inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }  


注释屏蔽掉,或者加 #if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600) 来仅屏蔽 VS2010。

接着修改 "stlport\stl\type_traits.h" 文件,在  66 行附近找到下面的代码:

[cpp]  view plain copy
  1. #ifdef _STLP_USE_BOOST_SUPPORT  
  2. #  include <stl/boost_type_traits.h>  
  3. #  include <boost/type_traits/add_reference.hpp>  
  4. #  include <boost/type_traits/add_const.hpp>  
  5. #endif /* _STLP_USE_BOOST_SUPPORT */  


在 #endif 前加入如下一行代码:

[cpp]  view plain copy
  1. #  include <boost/type_traits/remove_const.hpp>  

然后,启动 Visual Studio 2010 命令行方式,并定位到 STLport 主目录下,并按如下步骤执行命令(注意替换 %boostDir% 为具体的 Boost 路径):

[plain]  view plain copy
  1. configure msvc9 --with-static-rtl --with-dynamic-rtl --use-boost %boostDir%  
  2. cd build\lib  
  3. nmake clean install  
  4. rd /s /q obj  

然后,定位到 Boost 主目录下,并按如下步骤执行命令(注意替换 %boostDir% 为具体的 Boost 路径):

[plain]  view plain copy
  1. bootstrap  
  2. bjam stage --toolset=msvc-10.0 --stagedir="%boostDir%\vc10" link=static runtime-link=static threading=multi debug release  
  3. rd /s /q bin.v2  

对于 Boost 库,我自己喜欢采用嵌入源码方式使用,所以不做独立编译。以上步骤主要方便有需要的人。

然后,在 Visual Studio 2010 IDE 环境下打开一个项目,然后通过菜单"视图"->“属性管理器”打开“属性管理器”。

在 "Debug | Win32" 和 "Release | Win32" 下选择 "Microsoft.Cpp.Win32.user"。在点选时按 Ctrl 键进行多选。然后右键属性,打开属性页。

点选 "通用属性" 下的 "VC++ 目录" ,就可以看到有 "包含目录" 和 "库目录",在此添加 STLport 和 Boost 的引用路径(注意替换 %stlportDir% 和 %boostDir% 为具体的 STLport 和 Boost 路径):

STLport 包含目录:%stlportDir%\stlport
Boost 包含目录:%boostDir%
STLport 库目录:%stlportDir%\lib
Boost 库目录:%boostDir%\lib

然后在自己的项目中添加如下定义以便使 STLport 和 Boost 配合使用:

[cpp]  view plain copy
  1. #define _STLP_USE_STATIC_LIB    // 使用 STLport 静态库  
  2. #define _STLP_DEBUG             // STLport 启用 Debug 模式下的检查功能  
  3. #define _STLP_USE_BOOST_SUPPORT // STLport 与 Boost 库配合使用  

经过上面的处理后,就可以在 VS2010 下使用 STLport 和 Boost 了。

备注:

  1. 使用的 STLport 的版本是 5.2.1
  2. 使用的 Boost 的版本是 1.47.0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值