导航:首页 > 程序命令 > boost命令

boost命令

发布时间:2023-09-07 21:26:26

㈠ 在linux上运行boost库的问题

我系统是ubuntukylin14.04
然后今天去BOOST下了最新版的boost1.57版

下载下来的压缩文件亩宽我解压到/opt目团耐陆录下即/opt/boost_1_57_0

然后
cd /opt/塌顷boost_1_57_0;
./boststrap;
./b2

这里b2命令执行完成后显示:
The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

/opt/boost_1_57_0

The following directory should be added to linker library paths:

/opt/boost_1_57_0/stage/lib

然后我找了一段例子

C/C++ code?

1
2
3
4
5
6
7
8
9
10

#include<iostream>
#include<boost/bind.hpp>
using namespace std;
using namespace boost;
int fun(int x,int y){return x+y;}
int main(){
int m=1;int n=2;
cout<<boost::bind(fun,_1,_2)(m,n)<<endl;
return 0;
}

用g++编译的时候提示

bst.cxx:2:31: fatal error: boost/bind.hpp: 没有那个文件或目录
#include<boost/bind.hpp>
^
compilation terminated.

㈡ boost源码如何应用

下载Boost库,这里我选择下载boost_1_55_0.zip
解压boost文件到本地目录(如G:\boost_1_55_0),可以发现解压后的文件中有一个bootstrap.bat文件。
然后以管理员身份打开cmd窗口,

上述命令执行完毕后可以发现G:\boost_1_55_0下新生成了一个bjam.exe文件
在命令窗口中输入语句:bjam.exe
此过程将默认根据系统已经安装好的编译工具(VS2008,2010,2012,2013)等编译相应的Lib文件、头文件等。(此步骤大概需要10分钟)
可以看到msvc 12.0,这是因为我系统中已经安装过了VS2013
msvc : 8.0是VS2005
msvc : 10.0是VS2010
msvc : 12.0是VS2012、VS2013

第5步执行成功后会有如下信息提示
至此我们已经完成了boost库的安装,下面需要配置一下VS2013了。新建一个VS2013控制台应用程序(工程名为boostest),添加如下代码
#include "stdafx.h"
#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
cout << "number: " << a << " " << b << endl;
cout << "string: " << s0 << " " << s1 << endl;
int c = 0;
try{
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e){
cout << e.what() << endl;
}
return 0;
}
添加boostest工程的包含目录和库目录
包含目录添加 G:\boost_1_55_0
库目录添加 G:\boost_1_55_0\stage\lib

进入代码窗口编译并成功运行说明BOOST库确实已经配置成功,可以放心使用。

阅读全文

与boost命令相关的资料

热点内容
程序员那么可爱第30集免费看 浏览:635
如何下载老友麻将app 浏览:443
java路径参数 浏览:590
php命名空间使用 浏览:296
app的竞争力如何写 浏览:585
linux删除swp 浏览:588
pdfxchange40 浏览:75
车牌号码是哪个app 浏览:48
文件夹如何添加圆点 浏览:729
如何建立主索引命令 浏览:599
mac电脑怎么打开终端命令 浏览:741
androidvpn待机不断 浏览:756
硬盘的文件夹如何设置密码 浏览:384
plc定位编程 浏览:47
mac命令添加用户 浏览:815
android时间widget 浏览:393
qd128h压缩机参数 浏览:287
用单片机测车距 浏览:394
去哪里找加密的便签 浏览:19
武汉订酒店旅馆哪个app平台好 浏览:114