由于pthread库不是Linux系统默认的库,连接时需要使用库libpthread.a,所以在使用pthread_create创建线程时,在编译中要加-lpthread参数:
gcc   pthread.c -lpthread -o pthread
下面是codeblocks的修改:
设置>>编译器设置>>全局编译器设置>>链接器设置:
左侧链接库加入:/usr/lib64/libpthread.a
右侧其他链接器选项加入: -lpthread
如果你的libpthread.a不在lib64下可以用如下命令查找:

$ locate libpthread.a

codeblocks 多线程编程时出现:对pthread_create未定义的引用的解决方法

相关文章:

  • 2021-08-06
  • 2022-02-22
  • 2022-12-23
  • 2021-07-12
  • 2022-02-27
  • 2021-05-07
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案