博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gcc编译出现undefined reference to 'pthread create'的解决方法
阅读量:4105 次
发布时间:2019-05-25

本文共 461 字,大约阅读时间需要 1 分钟。

分享一下我老师大神的人工智能教程!零基础,通俗易懂!

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

      下面, 我们先看一个linux多线程程序:

#include 
#include
void* threadFunc(void* p){ while (1) {  printf("a"); }  return NULL;} int main (){ pthread_t id; pthread_create (&id, NULL, threadFunc, NULL);  while (1) {  printf("b"); }  return 0;}
      在linux上执行gcc thread.c,  结果出现编译错误undefined reference to 'pthread_create'。由于pthread库不是标准linux库, 所以出错。 改为gcc thread.c -lpthread 即可。

           

给我老师的人工智能教程打call!

这里写图片描述
你可能感兴趣的文章