boost_1_47_0的安装以及fadora15下Eclipse中的配置
来源:互联网 发布:java 登陆session用法 编辑:程序博客网 时间:2024/05/16 05:40
首先下载boost_1_47_0.tar.gz,
解压:tar-zxvf boost_1_47_0.tar.gz
进入目录:cdboost_1_47_0
运行脚本bootstrap.sh(如果默认该脚本没有可执行属性,请先改写其属性sudochmod a+x bootstrap.sh)
执行脚本./bootstrap.sh
按照执行后的提示,执行./b2(build boost的各个库)
bjam install(安装库到/usr/local/lib中)
在eclipse中配置编译和连接选项
Thefollowing directory should be added to compiler include paths:
/home/mweng/lib_3rd/boost_1_47_0
Thefollowing directory should be added to linker library paths:
/home/mweng/lib_3rd/boost_1_47_0/stage/lib
project->properties->gccc++ Linker->Libraries中填写使用的库(pthread),和引用库的路劲
运用thread库,编写多线程程序的时候,要首先引用库文件.a类型的库文件
project->properties->gccc++ Linker->Miscellaneous->Other objects中添加.a类型的库文件
/* * basic_atom.hpp * 线程安全的自动增量 * Created on: 2011-08-08 * Author: mweng */#include<boost/thread.hpp>using namespace boost;template<class T>class basic_atom:noncopyable{private:T n;typedef mutex mutex_t;mutex_t mu;public:basic_atom(T x=T()):n(x){}T operator++(){mutex_t::scoped_lock lock(mu);return ++n;}operator T(){return n;}};
/* * main.cpp * * Created on: 2011-08-08 * Author: mweng */#define BOOST_DATE_TIME_SOURCE#define BOOST_THREAD_NO_LIB#include<boost/thread.hpp>#include<boost/timer.hpp>#include<iostream>#include<cstring>#include"../head/basic_atom.hpp"using namespace std;using namespace boost;typedef basic_atom<int> atom_int;mutex io_mu;void printing(atom_int& x,const string &str){for(int i=0; i<5; i++){mutex::scoped_lock lock(io_mu);//锁定IO流,IO流是共享资源cout<<str <<":"<<++x<<endl;}}int main(){atom_int x;//原子操作的计数器thread(printing,ref(x),"hello");thread(printing,ref(x),"boost");this_thread::sleep(posix_time::seconds(2));return 1;}
结果:
hello:1
hello:2
hello:3
hello:4
hello:5
boost:6
boost:7
boost:8
boost:9
boost:10
- boost_1_47_0的安装以及fadora15下Eclipse中的配置
- centos环境下,maven的安装以及在eclipse中的配置(2017/07/06)
- Boost库的安装 (boost_1_47_0 + VS2008)
- Linux下JDK的配置以及eclipse的安装
- svn安装 以及在eclipse中的配置
- Eclipse下PlantUML 的安装及配置、Graphviz的安装和配置以及使用问题解决办法
- VS2008下编译boost_1_47_0
- vs2008下编译boost_1_47_0
- windows 7或者windows 10 vs2008-vs2013 下boost_1_47_0 安装的过程和出现的问题详解
- Tomcat免安装版的环境变量配置以及Eclipse下的Tomcat配置和测试
- maven安装配置以及在eclipse中的配置
- Eclipse的安装以及环境变量的配置
- Mac 下安装eclipse以及svn插件安装配置
- Maven的安装以及配置eclipse
- Eclipse的安装以及相关配置
- Maven的安装以及配置(Eclipse)
- tomcat下载安装以及在eclipse中的配置
- jdk,tomcat在myeclipse以及eclipse中的安装和配置
- 多线程各种基础小结
- 正在开发云ERP,欢迎大家指正
- 20110808
- CoreDataErrorThe model used to open the store is incompatible with the one used to create the store
- 乔布斯:创新就是对1000件事情说不
- boost_1_47_0的安装以及fadora15下Eclipse中的配置
- 另一个视角解读计算机编码-补码编码
- 正在开发云ERP,业务功能与天心CS ERP一模一样, 欢迎大家指正
- gSoap用户手册-2.8.3
- subversion和qt无窗口拖动
- pku 2396 budget
- floor函数,ceil函数
- 转:小结一下团队协作中的开源应用 转自:http://www.lingang.gd.cn/?action=show&id=329
- Android游戏开发之飞行射击类游戏原理实现(二十)