thread编译出错解决方法
2010-10-27 21:12
399 查看
编译:
zjz@ubuntu:~/scr/AT91SAM9260/BaseExp/4.thread/thread$ gcc thread.c
/tmp/cch3hL4i.o: In function `main':
thread.c:(.text+0xca): undefined reference to `pthread_create'
thread.c:(.text+0x112): undefined reference to `pthread_create'
thread.c:(.text+0x149): undefined reference to `pthread_join'
thread.c:(.text+0x15d): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
产生原因:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库libpthread.a,所以在使用pthread_create()创建线程,和其他一些与线程操作相关的函数时,需要链接该库。
这个错误跟以前遇到的那个使用<math.h>头文件时,很多数学函数的找不到的提示类似,那时候是在编译的时候添加“-lm”选项。
而此处产生这个问题原因是:
解决方法:
在编译中要加 -lpthread选项
zjz@ubuntu:~/scr/AT91SAM9260/BaseExp/4.thread/thread$ gcc thread.c -lpthread
zjz@ubuntu:~/scr/AT91SAM9260/BaseExp/4.thread/thread$ gcc thread.c
/tmp/cch3hL4i.o: In function `main':
thread.c:(.text+0xca): undefined reference to `pthread_create'
thread.c:(.text+0x112): undefined reference to `pthread_create'
thread.c:(.text+0x149): undefined reference to `pthread_join'
thread.c:(.text+0x15d): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
产生原因:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库libpthread.a,所以在使用pthread_create()创建线程,和其他一些与线程操作相关的函数时,需要链接该库。
这个错误跟以前遇到的那个使用<math.h>头文件时,很多数学函数的找不到的提示类似,那时候是在编译的时候添加“-lm”选项。
而此处产生这个问题原因是:
解决方法:
在编译中要加 -lpthread选项
zjz@ubuntu:~/scr/AT91SAM9260/BaseExp/4.thread/thread$ gcc thread.c -lpthread
相关文章推荐
- 〖Windows〗zigbee实验之cygwin编译tinyos.jar编译出错的解决方法
- eclipse新建android项目,编译出错解决方法
- android studio创建项目编译出错问题的解决方法
- 一个Shader编译出错的解决方法
- Qt编译出错--可选解决方法
- qt5 opencv3.0 配置后,编译出错问题的解决方法
- cocos2d-x-2.1.5版本在Xcode4.2中首次编译ccimage Semantic Issue出错解决方法
- tinyhttpd编译出错的解决方法
- QT4.4.3编译出错解决方法
- Windows Phone Toolkit 编译出错解决方法
- Ubuntu 编译opencv出错:‘GstMiniObjectClass’ does not name a type 解决方法
- FFmpeg编译出错undefined reference to `img_convert’的解决方法
- 使用modelsim仿真DDR3时编译出错的解决方法
- Ubuntu12.04编译ANDROID ICS出错解决方法
- Thuthesis在Tex live2015中编译出错的解决方法
- DirectX 9 SDK安装后在vs2010里编译BaseClasses出错问题解决方法
- VMWare在2.6.20内核下编译出错的解决方法
- Ubuntu14.04编译Allwinner lichee 两个出错解决方法
- UNIX网络编程卷1(第三版)关于源程序编译出错问题的详细解决方法