對pthread create未定義的引用

2021-08-08 20:55:04 字數 282 閱讀 2555

已經在c檔案中包含了執行緒的標頭檔案,可是編譯的時候卻報錯「對pthread_create未定義的引用「,原來時因為

pthread庫不是linux系統預設的庫,連線時需要使用庫libpthread.a,所以在使用pthread_create建立執行緒時,在編譯中要加-lpthread引數:gcc createthread.c -lpthread -o createthread. 加上這個以後編譯成功!

//-pthread可在g++下編譯成功,-lpthread還是出現「對pthread_create未定義的引用」。

對 pthread create 未定義的引用

注 本文由博主同步發布於 對 pthread create 未定義的引用 使用clion,在linux下編寫c 多執行緒程式 使用future和async cmake構建專案失敗,錯誤提示為 對 pthread create 未定義的引用 include include void th1 在函式 s...

pthread create 函式用法

天開始學習linux下用c開發多執行緒程式,linux系統下的多執行緒遵循posix執行緒介面,稱為pthread。include int pthread create pthread t restrict tidp,const pthread attr t restrict attr,void s...

pthread create函式詳解

pthread create是unix環境建立執行緒函式 include int pthread create pthread t restrict tidp,const pthread attr t restrict attr,void start rtn void void restrict a...