问题:
undefined reference to 'pthread_create'
undefined reference to 'pthread_join'
问题原因:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。
问题解决:
在编译中要加 -lpthread参数
gcc thread.c -o thread -lpthread�
/*thread_example.c : c multiple thread programming in linux
*author : falcon
*E-mail : tunzhj03@st.lzu.edu.cn
*/
1。Linux下的多线程编程
http://linux.chinaunix.net/doc/program/2001-08-11/642.shtml
2。pthread_delay_np(这里头有个关于posix条件变量的例子)
http://bbs.chinaunix.net/archiver/?tid-584593.html
3。pthread_join和段错误(非常感谢这里头的哥们,千万要看哦)
http://www.bczs.net/xml/2005/11/5/4374188.xml
4。posix线程编程指南[学习linux下多线程,不看这个你会后悔的]
http://www.linuxforum.net/forum/showflat.php?Cat=&Board=program&Number=294073&page=0&view=collapsed&sb=5&o=7&fpart=�