【发布时间】:2011-11-30 17:03:21
【问题描述】:
看到我有类似的代码
#include<stdio.h>
#include<pthread.h>
#include<string.h>
void* thread_function(void)
{
printf ("This is thread %d \n",pthread_self())
}
int main(int argc,char *argv[])
{
pthread_t thread_id[argc-1];
int i;
int status;
printf("argc is %d ",argc-1);
for(i=0;i<argc-1;i++)
{
pthread_create (&thread_id[i], NULL , &thread_function, NULL);
}
for(i=0;i<argc-1;i++)
pthread_join(thread_id[i],NULL);
}
现在我已经通过 MinGw 编译器 gcc.exe 4.6.1 编译它并得到 a.exe 现在我想问你 这个 a.exe 是否可以在其他 Windows 机器上工作没有安装 MinGW?
编辑: 当我通过 Cygwin 编译器编译这段代码并在没有 cygwin 的其他 Windows 机器上运行它的二进制文件时,它不会运行..说 cygwin.dll 缺少类似错误的东西
【问题讨论】:
-
您的 pthreads 可能有问题...请参阅 stackoverflow.com/questions/5057192/…