linux_thread_learn

由於是Linux新手,學習多線程時候,編寫的第一個線程 程序出現
undefined reference to 'pthread_create'
問題原因:
    pthread 庫不是 Linux 系統默認的庫,連接時需要使用庫libpthread.so,所以在使用pthread_create()創建線程。需要鏈接該庫。

    在編譯中要加 -lpthread參數
gcc -g -o my_thread_create my_thread_create.c -lpthread

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章