win8 64位 VS2013下boost库的编译

首先到boost库的官网http://www.boost.org/ 下载boost库的最新版本1.58.0, 下载到的压缩包boost_1_58_0.zip大小为117M。

将压缩包解压到任意目录下,我使用的是D盘的根目录。

需要说明的是,大多数的boost库是以头文件的形式给出来,不需要编译,包含对应的头文件(.hpp文件里已经包含了模板的内联实现)便可以使用。少部分库需要编译之后,链接对应的lib文件才能使用。这部分库包括一下部分等:

  • Boost.Filesystem
  • Boost.GraphParallel
  • Boost.IOStreams
  • Boost.MPI
  • Boost.ProgramOptions
  • Boost.Python (see theBoost.Python build documentation
    before building and installing it)
  • Boost.Regex
  • Boost.Serialization
  • Boost.Signals
  • Boost.System
  • Boost.Thread
  • Boost.Wave


在cmd下进入到解压之后的路径D:\boost_1_58_0,执行bootstrap.bat这个文件。

执行结束之后,会生成b2.exe这个文件。

执行b2.exe这个程序,开始编译,大概30分钟左右编译完成。编译完成之后,整个目录大小为2.49G。


配置:

新建一个工程,在工程属性里,

1、在配置属性的C/C++栏目,附加的包含目录里,添加路径D:\boost_1_58_0

2、在连接器的附加的库路径里,添加路径D:\boost_1_58_0\stage\lib   (注意是这个lib,而不是上层目录下的libs)



测试:

1. headers-only库的使用,只需要上边配置的第一步就行:

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

using namespace std;

template<typename T>
void f(const T& param)
{
    using std::cout;    
    using boost::typeindex::type_id_with_cvr;   
    // show T    
    cout << "T = "        
        << type_id_with_cvr<T>().pretty_name()  
        << '\n';    
    // show param's type    
    cout << "param = "        
        << type_id_with_cvr<decltype(param)>().pretty_name()    
        << '\n';   
    //cvr分别代表const,volatile,reference

}

int main()
{ 
    int i{ 0 };   
    const int* p = &i;   
    f(p);    
    system("pause");   
    return 0; 
}

正常输出:

2.需要链接.lib库的使用,需要上边配置的第一步和第二步。

#include <stdio.h>  
#include <string>  
#include <iterator>  
#include <boost/regex.hpp>  
#include <iostream>   

using namespace std;

int main(int argc, char *argv[])
{
	std::string str("infoasdf123unil98oasdfa686^&*(432");
	boost::regex e1("[0-9]+");

	std::string::const_iterator start, end;
	start = str.begin();
	end = str.end();

	boost::match_results<std::string::const_iterator> what;
	boost::match_flag_type flags = boost::match_default;

	while (regex_search(start, end, what, e1, flags))
	{
		cout << "finded number: " << string(what[0].first, what[0].second) << endl;
		start = what[0].second;
	}
	cin.get();
	return 0;
}
此时如果没有执行配置的第二部,会发生  fatal error LNK1104: cannot open file 'libboost_regex-vc120-mt-gd-1_58.lib' 的错误。

正常输出如下:


D:\boost_1_58_0目录下有本地的网页版帮助文档。




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值