您的位置:首页 > 运维架构 > Linux

centos(x86 64位系统)使用boost过程

2015-09-22 19:01 639 查看

1. 安装gcc,g++,make等开发环境
yum groupinstall
"Development Tools"
2. 安装boost
yum install boost boost-devel boost-doc
注意:默认的安装路径在/usr/lib64目录下
3. 例子
#include <boost/thread.hpp>
#include <iostream>void task1() {
// do stuff
std::cout << "This is task1!" << std::endl;
}void task2() {
// do stuff
std::cout << "This is task2!" << std::endl;
}int main (int argc, char ** argv) {
using namespace boost;
thread thread_1 = thread(task1);
thread thread_2 = thread(task2);// do other stuff
thread_2.join();
thread_1.join();
return 0;
}

4. makefile
g++ -I./inlcude -L./usr/lib64  asio_thread.cpp -lboost_thread-mt  -o example

注意:默认的安装路径在/usr/lib64目录下

5.结果

This is task2!
This is task1![/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: