views:

131

answers:

0

Hi, I cannot compile this code under 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);
}

I'm running on Windows 7 Ultimate x64 with Visual Studio 2008 and 2010 and I have installed:

  • Windows Subsystem for UNIX
  • Utilities and SDK for Subsystem for UNIX-based Applications in Microsoft Windows 7 and Windows Server 2008 R2

Include directories property of Visual Studio project is set to "C:\Windows\SUA\usr\include"

What I have to configure in order to compile and run (and possibly debug) pthreads programs in Visual Studio 2010 (or 2008)?