怎样彻底解决"undefined reference to `pthread_create'"问题

来源:互联网 发布:淘宝网二手手机商城 编辑:程序博客网 时间:2024/05/17 03:49
在编写pthread有关的程序时,编译时老是报"undefined reference to `pthread_create'"的错误,
原因是没有链接pthread相关的库,gcc加上-lrt就可以了.
我想怎样默认去链接这个库了?不要再加个"-lrt"了
也就是"/usr/lib/"下的libpthread.a,

应该在哪个配置文件中进行配置了?


问题解决:
    在编译中要加 -lpthread参数
    gcc thread.c -o thread -lpthread
    thread.c为你些的源文件,不要忘了加上头文件#include<pthread.h>
undefined reference to 'pthread_create'问题解决 - llqkk的专栏 - CSDN博客 (28 September 2009)
http://blog.csdn.net/llqkk/archive/2008/08/31/2854558.aspx

0 0
原创粉丝点击