首页 > 代码库 > (笔记)Linux线程编译undefined reference to 'pthread_create'
(笔记)Linux线程编译undefined reference to 'pthread_create'
在使用线程时,使用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‘
(笔记)Linux线程编译undefined reference to 'pthread_create'
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。