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

热点内容
程序员入门很难吗 浏览:101
70后程序员照片 浏览:191
一个普通程序员能干多久 浏览:934
adobe的PDF转换器 浏览:853
单片机数字码表汇编 浏览:477
单片机开发用的软件 浏览:152
程序员8个算法题 浏览:402
php题库系统 浏览:221
王牌战争文明重启选什么服务器 浏览:653
简述对称加密法 浏览:658
c语言数学编程 浏览:990
F1B命令 浏览:630
cs命令快捷键 浏览:852
阿里云购买服务器如何用现金支付 浏览:691
pythontime等待 浏览:989
单片机串行通信方式 浏览:499
android表格demo 浏览:278
安卓怎么让相册不显示网页 浏览:314
php文件系统源码 浏览:727
易信java 浏览:501