1. 安裝gcc,g++,make等開發環境ios
yum groupinstall
"Development Tools"
spa
2. 安裝boostcode
yum install boost boost-devel boost-doc
blog
注意:默認的安裝路徑在/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. makefilestring
g++ -I./inlcude -L./usr/lib64 test.cpp -lboost_thread-mt -o example
注意:默認的安裝路徑在/usr/lib64目錄下
5.結果
./example
This is task2! This is task1!