这是我编写的一个简单代码,用于在 Eclipse 中学习 Windows 7 操作系统上的多线程编程。
pthread_mutex_t double_release_001_glb_mutex_;
pthread_mutex_t * double_release_001_glb_mutex = & double_release_001_glb_mutex_;
void double_release_001_glb_mutex_lock () {}
void double_release_001_glb_mutex_unlock () {}
int double_release_001_glb_data = 0;
void * double_release_001_tsk_001 (void * pram)
{
pthread_mutex_lock (double_release_001_glb_mutex);
double_release_001_glb_data = (double_release_001_glb_data% 100) + 1;
pthread_mutex_unlock (double_release_001_glb_mutex);
return NULL;
}
void double_release_001 ()
{
pthread_t tid1;
pthread_mutex_init (double_release_001_glb_mutex, NULL);
pthread_create (& tid1, NULL, double_release_001_tsk_001, NULL);
pthread_join (tid1, NULL);
pthread_mutex_destroy (double_release_001_glb_mutex);
}
void double_release_001_tskentry_001 ()
{
while (1)
{
if (rand ())
{
double_release_001_tsk_001 (NULL);
}
}
}
但是当我构建它时,我收到一条错误消息
Description Resource Path Location Type
undefined reference to `_imp__pthread_create'
undefined reference to `_imp__pthread_create'
undefined reference to `_imp__pthread_create'
undefined reference to `_imp__pthread_create'
我已经包括pthread.h
. 有人可以帮我吗?