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

热点内容
程序员的中介模式 浏览:880
python中求两个字符串重复部分 浏览:494
如何查看收件发件服务器 浏览:110
linux配置android环境变量 浏览:132
android文字测量 浏览:883
压力大金钱怎么解压 浏览:641
生男算法 浏览:770
php读取当前目录 浏览:439
说一个可以连接的服务器地址 浏览:508
操盘手1pdf 浏览:536
什么app新人注册可以免费买东西 浏览:601
flexjava教程 浏览:119
vnc访问云服务器 浏览:484
java获取list长度 浏览:693
linuxc打开文件夹 浏览:891
分析员设计员程序员职责 浏览:711
如何修改安卓内购游戏 浏览:439
什么是工具箱app 浏览:249
linuxtab空格 浏览:10
python调用linux的命令行 浏览:585