Well, Now that you say that. I will simplify my makefile, but then it doesn't know what pthread_create is.. or anything related to pthread.
C:\Users\Viper\Documents\Cpp\Pthreads>"C:\Program Files\SlickEdit 2009\win\vsbuild" -signal 9009 -command make -f "Makefile" CFG=Debug VSLICKERRORPATH="C:\Users\Viper\Documents\Cpp\Pthreads" make -f Makefile CFG=Debug g++ -c -g -o "Debug/Pthreads.o" Pthreads.cpp Pthreads.cpp:10:21: pthread.h: No such file or directory Pthreads.cpp: In function `void* PrintHello(void*)': Pthreads.cpp:22: error: `pthread_exit' undeclared (first use this function) Pthreads.cpp:22: error: (Each undeclared identifier is reported only once for each function it appears in.) Pthreads.cpp: In function `int main(int, char**)': Pthreads.cpp:27: error: `pthread_t' undeclared (first use this function) Pthreads.cpp:27: error: expected `;' before "threads" Pthreads.cpp:32: error: `threads' undeclared (first use this function) Pthreads.cpp:32: error: `pthread_create' undeclared (first use this function) Pthreads.cpp:39: error: `pthread_exit' undeclared (first use this function) mingw32-make: *** [Debug/Pthreads.o] Error 1 The Pthreads.cpp file is perfect, I've tried it in Linux.. /***************************************************************************** * FILE: hello_arg3.c * DESCRIPTION: * This "hello world" Pthreads program demonstrates an unsafe (incorrect) * way to pass thread arguments at thread creation. In this case, the * argument variable is changed by the main thread as it creates new threads. * AUTHOR: Blaise Barney * LAST REVISED: 01/30/09 ******************************************************************************/ #include <pthread.h> #include <stdio.h> #include <stdlib.h> #define NUM_THREADS 8 void *PrintHello(void *threadid) { long taskid; printf("threadid=0x%x\n", threadid); // sleep(1); taskid = (long) threadid; printf("Hello from thread %ld\n", taskid); pthread_exit(NULL); } int main(int argc, char *argv[]) { pthread_t threads[NUM_THREADS]; int rc; long t; for ( t=0;t<NUM_THREADS;t++ ) { printf("Creating thread %ld\n", t); rc = pthread_create(&threads[t], NULL, PrintHello, (void *) t); if ( rc ) { printf("ERROR; return code from pthread_create() is %d\n", rc); exit(-1); } } pthread_exit(NULL); } Dave Korn-6 wrote: > > Afflictedd2 wrote: > >> I'm trying to build a simple program using pthreads, but I get the >> following >> errors, why? > >> g++ -c -g -o "Debug/Pthreads.o" -I/Cygwin/usr/include Pthreads.cpp > ^^^^^^^^^^^^^^^^^^^^^^ > > Don't do that, for a start. The compiler knows about all the system's > default include directories already, and has them in a carefully-placed > search > order. If you're lucky, it will just ignore that -I option; if you're > unlucky > it might be messing things up. > > If that doesn't fix it you'll need to try and show us a small simple > testcase; sounds like whatever it is, we'd just need the first ten lines > of > your Pthreads.cpp file (up to the #include that prompts the first errors) > in > order to try and reproduce it. > > cheers, > DaveK > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > > > -- View this message in context: http://old.nabble.com/Help-with-errors-while-compiling-tp26683356p26684236.html Sent from the Cygwin list mailing list archive at Nabble.com. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple