1

我无法在 SUA 下编译此代码:

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void * thread_function(void *arg) {
     printf("thread_function started. Arg was %s\n", (char *)arg);
     // pause for 3 seconds
     sleep(3);
     // exit and  return a message to another thread
     // that may be waiting for us to finish
     pthread_exit ("thread one all done");
}
int main() {
     int res;
     pthread_t a_thread;
     void *thread_result;
     // create a thread that starts to run     ‘thread_function’
     pthread_create (&a_thread, NULL,
     thread_function, (void*)"thread one");
     printf("Waiting for thread to finish...\n");
     // now wait for new thread to finish
     // and get any returned message in ‘thread_result’
     pthread_join(a_thread, &thread_result);
     printf("Thread joined, it returned %s\n", (char *)thread_result);
     exit(0);
}

我正在使用 Visual Studio 2008 和 2010 在 Windows 7 Ultimate x64 上运行,并且我已经安装了:

  • 适用于 UNIX 的 Windows 子系统
  • 适用于 Microsoft Windows 7 和 Windows Server 2008 R2 中基于 UNIX 应用程序的子系统的实用程序和 SDK

Visual Studio 项目的包含目录属性设置为“C:\Windows\SUA\usr\include”

为了在 Visual Studio 2010(或 2008)中编译和运行(可能调试)pthreads 程序,我必须配置什么?

4

0 回答 0