linux¶àÏ̱߳à³É - Linux/UnixÉçÇø / ³ÌÐò¿ª·¢Çø
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
void *first()
{
printf("first pthread-----ABC\n");
}
void *second()
{
printf("second pthread-----ABC\n");
}
int main()
{
printf("mian pthread----ABC\n");
pthread_t fthread;
pthread_t sthread;
pthread_create(&fthread,NULL,first,NULL);
pthread_create(&sthread,NULL,second,NULL);
pthread_join(fthread,NULL);
pthread_join(sthread,NULL);
return 0;
}
ÎÒ±àÒëÌáʾ´íÎóÈçÏÂ
fily@zhaoyf:/media/work/develop/iscsitarget/usr$ gcc -o thread thread.c
/tmp/ccRbUIwW.o: In function `main':
thread.c:(.text+0x4e): undefined reference to `pthread_create'
thread.c:(.text+0x66): undefined reference to `pthread_create'
thread.c:(.text+0x74): undefined reference to `pthread_join'
thread.c:(.text+0x82): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
¸ßÊÖ°ïæ£¬ÎÒ´íÔÚÄÄÀïÁË£¿
ÎÒʹÓõÄÊÇdebian5linux{{
Ïà¹ØÎÊ´ð£º
ÒýÓÃÄÚÈÝvsking 2009-12-25 22:56:52
ÏÖÔÚÊÇwin2008ºÍiis8µÄʱ´úÁË£¬²»Òª»¹Í£ÁôÔÚiis5ʱ´ú£¬win2008±»ÆÀΪʮ¼Ñ²Ù×÷ϵͳ֮Êײ»ÊÇżȻµÄ£¬ÄãÒªÊÇ..
ÎÒµÄÎÊÌâÊÇ£º
×î½üÏëÂò¸ö·þÎñÆ÷£¬¿´ÁËdellÉϵÄϵͳ¶¨ÖÆÑ¡Ôñ£¬Ò»Ð© ......
int dValue = pthread_mutex_lock(&g_ThreadMutex);
if (0 != dValue)
{
. pthread_mutex_unlock(&g_ThreadMutex);
. return pToDealing;
}
----------------ʧ°Üºó£¬ÔÙµ÷ÓúìÉ«²¿·Ö£¬»á²»»áµ¼Ö³ÌÐ ......
> Message: 1
> Date: Sat, 24 Apr 2010 11:31:02 +1000
> from: Crossfire <xfire@xware.cx>
> Subject: Re: [coders] New to Kernel programming and device drivers
> To: coders@slug. ......