c++11支持多线程,底层仍是使用的lphtread,因此编译的时候须要加上相关的一些参数。c++
下面是我使用codeblokcs编译成功的例子多线程
第一行是编译参数 须要 -std=c++11 lpthread
ui
第二行是连接参数 须要 -Wl,--no-as-needed -lpthread
线程
-------------- Build: Debug in thread (compiler: GNU GCC Compiler)---------------
g++ -Wall -fexceptions -g -std=c++11 -lpthread -lphtread -I/usr/local/include/boost -c /root/codewok/thread/main.cpp -o obj/Debug/main.o
g++ -L/usr/local/lib -o bin/Debug/thread obj/Debug/main.o -Wl,--no-as-needed -lboost_system -lboost_thread -lpthread
Output file is bin/Debug/thread with size 107.79 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
-------------- Run: Debug in thread (compiler: GNU GCC Compiler)---------------
Checking for existence: /root/codewok/thread/bin/Debug/thread
Executing: gnome-terminal --disable-factory -t thread -x /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /root/codewok/thread/bin/Debug/thread (in /root/codewok/thread/.)
Process terminated with status 0 (0 minute(s), 1 second(s))
c++11