If you are going to compile a C program with pthread.h in LINUX using GCC or G++ you will have to use –lpthread option after the compile command.

gcc xyz.c -o xyz -lpthread

Here,

gcc is compiler command (compiler name)

xyz.c is a source file name.

-o is an option to create objcect file.

xyz is the name of object (binary) file.

-lpthread is an option for pthread.h

for more details here is the link conatining complete article on it.

Compiling C program with pthread.h in Linux.

pthread库不是 Linux 默认的库,有些 Library 默认使用pthread但是在介绍的时候没有说明,导致编译时出错。-lpthread-pthread两种写法好像都可以。

相关文章:

  • 2021-09-12
  • 2021-11-19
  • 2021-12-16
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-01-06
  • 2021-10-17
  • 2021-10-30
相关资源
相似解决方案