导航:首页 > 程序命令 > 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命令相关的资料

热点内容
Qt环境的编译软件放到linux 浏览:212
联创打印系统怎么连接服务器 浏览:935
杭州行政命令 浏览:160
如何查找服务器日志 浏览:801
加密的钥匙扣怎么写 浏览:579
文件夹更新不了怎么办 浏览:475
压缩机指示灯亮是什么原因 浏览:956
什么app订酒店半价 浏览:765
中老年解压神器 浏览:243
讯飞语音ttsandroid 浏览:468
腰椎压缩性骨折术后能坐车吗 浏览:507
python类装饰器参数 浏览:347
均线pdf微盘 浏览:791
女生喜欢玩的解压游戏 浏览:442
支付宝暗号加密操作 浏览:133
柯洁在哪个app下围棋 浏览:751
平板用什么app看内在美 浏览:609
cad计算机命令 浏览:173
邮箱设置域名服务器错误什么意思 浏览:671
硬盘解压失败受损蓝屏 浏览:654