当前位置:  技术问答>linux和unix

为什么pthread_create`编译通不过

    来源: 互联网  发布时间:2015-08-03

    本文导语:  #include  #include  #include  void donothing() { } int main(int argc, char *argv[]) {   pthread_t thread;   pthread_create(&thread,NULL,(void*)donothing,NULL); } 下面是编译命令: [groupmerit@localhost mutithread]$ gcc -c main.c [groupmerit@localhost mutithrea...

#include 
#include 
#include 
void donothing()
{
}
int main(int argc, char *argv[])
{

  pthread_t thread;
  pthread_create(&thread,NULL,(void*)donothing,NULL);
}

下面是编译命令:
[groupmerit@localhost mutithread]$ gcc -c main.c
[groupmerit@localhost mutithread]$ gcc -o main main.o
main.o(.text+0x33): In function `main':
: undefined reference to `pthread_create'
collect2: ld returned 1 exit status

为什么生成可执行文件会报pthread_create没定义





|
gcc -o main main.o -lpthread
要连接库。

    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • Linux里的pthread_create会不会阻塞啊?
  • 关于pthread_create函数的问题
  • pthread_create的问题
  • pthread_create函数执行问题
  • 包含了#include <pthread.h>,为什么还有pthread_create错误?
  • 无法使用pthread_creat()函数的问题
  • 请问:linux下如何将一个类的指针作为参数传给pthread_create创建的线程?
  • 有关使用pthread_creat时的参数传递问题!!!
  • pthread_create 的问题 ,求救大家!!!
  • linux下进程和线程的区别(fork(),pthread_create())?
  • REDHAT7.2提示:undefined reference to "pthread_create"
  • 请问:为什么我在守护进程里面用pthread_create来启动线程,经常会卡在那里阿?
  • pthread_create 为何报 Segmentation fault?
  • ★pthread_create 与 thr_create的区别是什么?★
  • 求助!!undefined reference to 'pthread_create'
  • pthread_create创建线程问题
  • 急!同一个c文件里vfork();pthread_create();两个函数,Makefile该怎么写?谢谢
  • No manual entry for pthread_create,我安了manpages-dev和glibc-doc
  • 为什么pthread_create创建线程出错.有完整代码,哪儿错了,大家给试试.
  • pthread_create函数返回值问题


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3