小编kot*_*kot的帖子

如何在Ubuntu 10.04中安装C++ API文档?

我已经安装了gcc.

对于 man 2 cout

root@kota-laptop:/# man 2 cout
No manual entry for cout in section 2

root@kota-laptop:/# man 2 printf
No manual entry for printf in section 2
See 'man 7 undocumented' for help when manual pages are not available.
Run Code Online (Sandbox Code Playgroud)

linux

7
推荐指数
1
解决办法
2621
查看次数

请帮助编译这个程序

#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
#include<unistd.h>

void *WriteNumbers(void *threadArg)
{
 int start, stop;
 start = atoi((char *)threadArg);
 stop = start + 10;

 while(start<stop)
 {
  printf("%d\n", start++);
  sleep(1);
 }
}

int main(int argc, char **argv)
{
 pthread_t thread1, thread2;

 // create the threads and start the printing 
 pthread_create(&thread1, NULL, WriteNumbers, (void *)argv[1] );
 pthread_create(&thread2, NULL, WriteNumbers, (void *)argv[2]);

 pthread_join(thread1, NULL);
 pthread_join(thread2, NULL);

 return 0;
}
Run Code Online (Sandbox Code Playgroud)
gcc -o pthread pthread.c 
/tmp/cckJD3rd.o: In function `main':
pthread.c:(.text+0x7a): undefined reference to `pthread_create'
pthread.c:(.text+0xa2): undefined reference to `pthread_create' …
Run Code Online (Sandbox Code Playgroud)

c linux pthreads

0
推荐指数
2
解决办法
622
查看次数

标签 统计

linux ×2

c ×1

pthreads ×1