|
我用的是Red Hat EnterPrise Linux ES(2.4.21-9.EL) .
我用以下代码测试.
int main()
{
printf(" OSIX version is set to %ld\n", _POSIX_VERSION);
if (_POSIX_VERSION < 199506L)
{
if (_POSIX_C_SOURCE >= 199506L)
{
printf("Sorry, your system does not support POSIX1003.1c threads\n");
}
else
{
printf("Try again with -D_POSIX_C_SOURCE = 199506L\n");
}
}
else
{
printf("Your system supports POSIX1003.1c threads.\n");
#ifdef _POSIX_THREAD_RPIORITY_SCHEDULING
printf("including support for priority scheduling\n");
#else
printf("But does not support priority scheduling\n");
#endif
}
exit(EXIT_SUCCESS);
}
输出结果如下: POSIX version is set to 199506
Your system supports POSIX1003.1c threads.
But does not support priority scheduling
我的一个程序名为thread1.c 头文件包函了 pthread.h
我使用 gcc -D_REENTRANT thread1.c -o thread
输出结果如下:
/tmp/ccAofBGq.o(.text+0x21): In function `main':
: undefined reference to `pthread_create'
为什么会这样呢? 谁能帮我一下吗? |
|