剛在Ubuntu16.04 上用Clion寫一個"單生產者-單消費者"的線程的程序,源程序可以參考下面的網址
https://www.cnblogs.com/haippy/p/3252092.html
在編譯的時候編譯器給的提示是:?undefined reference to 'pthread_create'
解決辦法就是在CMakeLists.txt文件里 的add_executable() 下面用target_link_libraries()中加上鏈接庫 -lpthread.
例如
add_executable(spsc main.cpp)
target_link_libraries(spsc? -pthread)