-lpthread

发布时间 2023-11-21 11:39:49作者: 野原丶广志

thread_create函数编译时报错:undefined reference to 'pthread_create'

pthread 库不是 Linux 系统默认的库,所以在编译使用pthread_create()创建线程的程序时,需要显式指定 -lpthread参数。

g++ thread.c -o thread <strong>-lpthread