现在的位置: 首页 > 综合 > 正文

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

2013年03月09日 ⁄ 综合 ⁄ 共 716字 ⁄ 字号 评论关闭

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

yum
groupinstall 
"Development
Tools"


2. 安装boost

 yum
install boost boost-devel boost-doc

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


3.
例子

  1. #include <boost/thread.hpp>  
  2. #include <iostream>  
  3.   
  4. void task1() {   
  5.     // do stuff  
  6.     std::cout << "This is task1!" << std::endl;  
  7. }  
  8.   
  9. void task2() {   
  10.     // do stuff  
  11.     std::cout << "This is task2!" << std::endl;  
  12. }  
  13.   
  14. int main (int argc, char ** argv) {  
  15.     using namespace boost;   
  16.     thread thread_1 = thread(task1);  
  17.     thread thread_2 = thread(task2);  
  18.   
  19.     // do other stuff  
  20.     thread_2.join();  
  21.     thread_1.join();  
  22.     return 0;  
  23. }  

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!

【上篇】
【下篇】

抱歉!评论已关闭.