boost_1_51_0.zip 下载并解压到C盘根文件夹
二、编译boost
1、生成生命行程序
执行bootstrap.bat
2、编译
执行b2.exe,完成后显示:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:/boost_1_51_0
The following directory should be added to linker library paths:
C:\boost_1_51_0\stage\lib
三、使用boost
1、创建一个win32 console
2、引用bootst
C/C++ ->Additional Include Directories: C:\boost_1_51_0
Linker->Additional Library Directories: C:\boost_1_51_0\stage\lib
答早 Linker->Input->Additional Dependencies :libboost_signals-vc110-mt-gd-1_51.liblibboost_regex-vc110-mt-gd-1_51.lib
3、Code如下:
#include "stdafx.h"
#include <boost/regex.hpp>
#include <boost/signals.hpp>
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <卖中cassert>
struct print_sum {
void operator()(int x, int y) const { std::cout <<x+y <<std::endl}
}
struct print_product {
void operator()(int x, int y) const { std::cout <<x*y <<std::endl}
}
int _tmain(int argc, _TCHAR* argv[])
{
boost::signal2<void, int, int, boost::last_value<void>, std::string>sig
sig.connect(print_sum())
sig.connect(print_product())
sig(3, 5)
std::string line
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" )
while (std::cin)
{
std::getline(std::cin, line)
boost::smatch matches
if (boost::regex_match(line, matches, pat))
std::cout <<matches[2] <<std::endl
}
return 0
}
示例程序在vs2012下通过,输中举山出:
8
15
Qt Creator+MinGW+boost特殊函数的使用示例:
先编译和安装boost:
[plain] view plain 郑缺copy
bootstrap.bat gcc
.\b2 --toolset=gcc --prefix=E:\boost install
新建qt控制台项目,然后在*.pro文件中添加一行:[plain] view plain copy
INCLUDEPATH += E:/boost/include/boost-1_53
测试acosf和贝赛尔函数,下面是main.cpp
[cpp] view plain copy
#include <QCoreApplication>
#include <boost/math/special_functions/acosh.hpp>
#include <boost/math/special_functions/bessel.hpp>
#include <iostream>
using namespace boost::math
using namespace boost::math::detail
int 含丛手main(int argc, char *argv[])
{
QCoreApplication a(argc, argv)
std::cout<<"Test Boost:"<<std::endl
std::cout<谈嫌<acosh(2.5)<<std::endl
std::cout<<bessel_i0(3.2)<<std::endl
std::cout<<"Test Finished!"<<std::endl
return a.exec()
}
程序部分界面和运行结果为:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)