centos使用boost過程


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!
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM