[英]ld: library not found for -lpthread
I am trying to compile a program on Mac 10.9.1 but am facing a problem. 我正在尝试在Mac 10.9.1上编译程序,但遇到了问题。 On running gcc command with -lpthread flag to create a dylib , the linking fails with the following error. 在运行带有-lpthread标志的gcc命令以创建dylib时,链接失败,并显示以下错误。
ld : library not found for -lpthread.
libpthread.dylib is located in /usr/lib/ libpthread.dylib位于/ usr / lib /
Can anyone help. 谁能帮忙。
Thanks 谢谢
It sounds like you need to specify the directory that contains the libpthread.dylib
file, which on most Macs is /usr/lib
. 听起来您需要指定包含libpthread.dylib
文件的目录,在大多数Mac上该文件是/usr/lib
。 Do this using the -L
argument to ld
, as in ld -L/usr/lib -lpthread
. 使用ld
的-L
参数来执行此操作,就像ld -L/usr/lib -lpthread
。
Edit: gcc
also accepts the -L
argument. 编辑: gcc
还接受-L
参数。
Using -lpthread
is technically not the right way to do it. 从技术上来说,使用-lpthread
并不是正确的方法。 You get better, more portable results by using -pthread
on the GCC command line. 通过在GCC命令行上使用-pthread
,可以获得更好,更可移植的结果。 Use it for the compile and the link. 使用它进行编译和链接。 It will set important preprocessor definitions and link the necessary libraries. 它将设置重要的预处理器定义并链接必要的库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.