首页 > 其他 > 详细

centos使用boost过程

时间:2015-09-11 23:23:56      阅读:771      评论:0      收藏:0      [点我收藏+]

1. 安装gcc,g++,make等开发环境

yum groupinstall "Development Tools"

 

2. 安装boost

 yum install boost boost-devel boost-doc

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

 

#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  test.cpp -lboost_thread-mt  -o example
注意:默认的安装路径在/usr/lib64目录下

5.结果
./example
This is task2!
This is task1!
 

centos使用boost过程

原文:http://www.cnblogs.com/echosong/p/4802237.html

(1)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!