Vs2010配置boost库,LINUX boost安装

from http://blog.sina.com.cn/s/blog_4c98b96001009v40.html

http://www.yiran.org/boost-149-under-vs2010/

 

主页:http://www.boost.org/

实际下载页面:http://sourceforge.net/project/showfiles.php?group_id=7586

1:

打开程序菜单,选择Visual Studio Tools里面的 Visual Studio 命令提示

2:

转到解压后的Boost所在目录,输入Bootstrap,执行完毕会生成b2.exe。
输入(目录下的bjam.exe和b2.exe是完全相同的,可以互换)
b2 --toolset=msvc-10.0 --build-type=complete stage
(若要构建Boost 64位版本函数库,则输入b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage
编译时间较长,耐心等待。

3:

打开VS2010,新建空C++项目,点击项目菜单中的项目属性,找到配置属性->VC++目录,在“包含目录”中添加 [Boost所在目录],

如:C:\boost_1_55_0\,在“库目录”中添加 [Boost目录]\stage\lib,如:C:\boost_1_55_0\stage\lib,保存设置,至此Boost配置完成。

附:VS2010 静态链接 Boost 函数库的配置方法:
打开项目属性->配置属性->C/C++->代码生成,选择“运行库”为“多线程 (/MT)”(如选择“多线程 DLL (/MD)”,则为动态链接 Boost 库)。

是为记。

若选/MT则出现:

1>libcmtd.lib(dbgheap.obj) : error LNK2005: __heap_alloc 已经在 LIBCMT.lib(malloc.obj) 中定义
1>libcmtd.lib(dbgheap.obj) : error LNK2005: __recalloc 已经在 LIBCMT.lib(recalloc.obj) 中定义
1>libcmtd.lib(dbgheap.obj) : error LNK2005: __msize 已经在 LIBCMT.lib(msize.obj) 中定义
1>libcmtd.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook 已经在 LIBCMT.lib(dbghook.obj) 中定义
1>libcmtd.lib(isctype.obj) : error LNK2005: __isctype_l 已经在 LIBCMT.lib(isctype.obj) 中定义
1>libcmtd.lib(isctype.obj) : error LNK2005: __isctype 已经在 LIBCMT.lib(isctype.obj) 中定义
1>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
1>LIBCMT.lib(crt0init.obj) : warning LNK4098: 默认库“libcmtd.lib”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
1>E:\VCProject\TestShareMute\Debug\TestBoost.exe : fatal error LNK1169: 找到一个或多个多重定义的符号

修改:项目属性-配置属性-链接器-输入-忽略特定的库:libcmtd.lib,还是出现以上错误

改为添加:附加依赖项中才不会出现以上错误

 #include<iostream>
#include <boost/regex.hpp>
using namespace std;

int main()
{
    // 3 digits, a word, any character, 2 digits or "N/A", 
    // a space, then the first word again
    boost::regex reg("\\d{3}([a-zA-Z]+).(\\d{2}|N/A)\\s\\1");


    std::string correct="123Hello N/A Hello";
    std::string incorrect="123Hello 12 hello";


    assert(boost::regex_match(correct,reg)==true);
    assert(boost::regex_match(incorrect,reg)==false);
    cout<<"Hello Boost !"<<endl;
}

LINUX boost安装

http://blog.csdn.net/zgl_dm/article/details/8363843

用以下测试用例

1.测试代码

#include <boost/lexical_cast.hpp>
#include <iostream>


int main()
{
  using boost::lexical_cast;
  int a= lexical_cast<int>("123456");
  double b = lexical_cast<double>("123.456");
  std::cout << a << std::endl;
  std::cout << b << std::endl;
  return 0;
}
2.编译,运行
 g++ -g -o test testboost.cpp
#ls
test  test.cpp
# ./test 
123456
123.456


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值