我想编译提供给我的程序。我在Makefile注意到它运行的命令pthread库包含在(链接?)步骤
g++ -o test [...] -lpthread
我注意到pthread库文件是/lib/libpthread.so.0,但是当我试图让目标,它给了我这个错误:
/usr/bin/ld: cannot find -lpthread
collect2: ld returned 1 exit status
我该如何解决这个问题?
我想编译提供给我的程序。我在Makefile注意到它运行的命令pthread库包含在(链接?)步骤
g++ -o test [...] -lpthread
我注意到pthread库文件是/lib/libpthread.so.0,但是当我试图让目标,它给了我这个错误:
/usr/bin/ld: cannot find -lpthread
collect2: ld returned 1 exit status
我该如何解决这个问题?
为了使用-lpthread
,您需要一个libpthread.a
库存档,这是用于静态链接的。 libpthread.so.0
是一个共享对象,意味着它用于动态链接。请参阅GCC Link Options
可能不会解决您的问题,但您应该使用'-pthread'而不是'-lpthread'。 – Mat
'-Wl, - verbose'选项会告诉你GCC在哪里寻找库,这可能会帮助你找出为什么它找不到它。有关更多详细信息,请参阅http://stackoverflow.com/a/11481258/12711。 –