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

来源:互联网 发布:maya软件下载 编辑:程序博客网 时间:2024/06/04 20:45


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!
0 0
原创粉丝点击