linux下编译多线程程序, undefined reference to `pthread_create',undefined reference to `pthread_join'
2017-10-23 13:41
756 查看
问题描述:hero@ubuntu:~/WORK/for_xc7z035/app/sdr_7010$ gcc -o ./test ./test.c
/tmp/cc7BcXdf.o: In function `main':
test.c:(.text+0x1d7): undefined reference to `pthread_create'
test.c:(.text+0x1fb): undefined reference to `pthread_create'
test.c:(.text+0x21f): undefined reference to `pthread_create'
test.c:(.text+0x233): undefined reference to `pthread_join'
test.c:(.text+0x247): undefined reference to `pthread_join'
test.c:(.text+0x267): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
问题原因:
1, pthread 库不是 Linux 系统默认的库,在编译多线程程序时,需要在编译命令中添加链接libpthread.a库。
2,忘了加上头文件#include<pthread.h>
问题解决:
在编译中要加 -lpthread参数
gcc ./test.c -o ./test -lpthread
/tmp/cc7BcXdf.o: In function `main':
test.c:(.text+0x1d7): undefined reference to `pthread_create'
test.c:(.text+0x1fb): undefined reference to `pthread_create'
test.c:(.text+0x21f): undefined reference to `pthread_create'
test.c:(.text+0x233): undefined reference to `pthread_join'
test.c:(.text+0x247): undefined reference to `pthread_join'
test.c:(.text+0x267): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
问题原因:
1, pthread 库不是 Linux 系统默认的库,在编译多线程程序时,需要在编译命令中添加链接libpthread.a库。
2,忘了加上头文件#include<pthread.h>
问题解决:
在编译中要加 -lpthread参数
gcc ./test.c -o ./test -lpthread
相关文章推荐
- linux下开发,解决cocos2d-x中编译出现的一个小问题, undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
- gcc编译线程程序需带-lpthread选项(否则出错:undefined reference to `pthread_create')
- Linux下eclipse编译C/C++程序遇到 undefined reference to `pthread_create'的异常解决办法
- 在liunx编译C语言程序出现Undefined reference to pthread_create in Linux 错误*
- Linux下运行多线程——undefined reference to 'pthread_create'问题两种解决方法
- 在linux下编译线程程序undefined reference to `pthread_create'
- Linux 编译报错 -- undefined reference to 问题解决方法 (具体'pthread_create'和opencv看文章最后两条)
- Linux 编写线程,调用pthread_create,pthread_join出现undefined reference to..问题
- Linux 编译报错 undefined reference to `pthread_create'
- linux编译出现undefined reference to symbol 'pthread_create错误解决方案
- Ubuntu下使用Eclipse编译pthread程序错误undefined reference to `pthread_create'
- linux下开发,解决cocos2d-x中编译出现的一个小问题, undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
- UNIX环境高级编程中的11章程序11-2编译问题---undefined reference to `pthread_create'
- Linux下undefined reference to ‘pthread_create’问题解决
- 编译错误----undefined reference to 'pthread_create'问题解决
- eclipse 函数编译时报错:undefined reference to `pthread_create’
- Linux下undefined reference to ‘pthread_create’问题解决
- pthread_create函数编译时报错:undefined reference to 'pthread_create'
- pthread_create函数编译时报错:undefined reference to 'pthread_create'
- linux 创建线程问题undefined reference to 'pthread_create'