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

热点内容
程序员表白代码大全可复制 浏览:365
手机如何共享web服务器 浏览:956
php接口有什么用 浏览:382
iis如何安装php 浏览:791
k5嗜血魔键安卓怎么调好用 浏览:834
建行app中如何添加银行卡 浏览:281
简便算法100点 浏览:161
如何创新我的世界服务器 浏览:881
战地怎么看服务器地址 浏览:348
vue怎么打包放上服务器 浏览:165
为什么安卓服夏日活动没有兔子头 浏览:894
pubg为什么显示服务器连接失败 浏览:650
阿里云扫码登录服务器 浏览:971
化学基础pdf 浏览:896
51单片机晶码管 浏览:281
怎么查服务器假死原因日志在哪看 浏览:277
扫描pdf文件 浏览:926
解压密码百度云在线解压 浏览:767
传播学算法推荐 浏览:749
我的世界网络游戏如何查找服务器 浏览:258