pthread库包含在(链接?)步骤中

时间:2012-10-15 05:07:19

标签: g++ pthreads

我正在尝试编译提供给我的程序。我在Makefile中注意到它运行命令

g++ -o test [...] -lpthread

我注意到pthread库文件在/lib/libpthread.so.0中,但是当我尝试制作目标时,它给了我这个错误:

/usr/bin/ld: cannot find -lpthread
collect2: ld returned 1 exit status

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:-2)

要使用-lpthread,您需要一个libpthread.a库存档,这适用于静态链接。 libpthread.so.0是一个共享对象,这意味着它用于动态链接。见GCC Link Options