在使用线程时,使用gcc或arm-linux-gcc编译时,会出现错误:undefined reference to 'pthread_create'

 

主要是以下两种原因:

1、#include <pthread.h>  请确认头文件是否添加

2、-lpthread 编译选项,即在编译时需添加额外的编译选项,如使用arm-linux-gcc编译lc300-led-test.c文件,命令正确应该如下:

    arm-linux-gcc -o lc300-led-test lc300-led-test.c -lpthread

    请注意后面的-lpthread,特别是-后边的'l',link = 'l'

相关文章:

  • 2022-12-23
  • 2021-08-19
  • 2021-08-04
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案