Matt Phillips

Newbie trying to use pthreads

Discussion created by Matt Phillips on Dec 8, 2006

Hello,

 

Some of this may apply to using any user-supplied library and some of this may be particular to pthreads (http://sourceware.org/pthreads-win32/). Anyway, I'm trying to test out some sample pthreads code in CodeWarrior, and here's what happened:

 

1) I put the pthreads folder in the main CodeWarrior directory and #include in the header. When I tried to compile, I got errors like

 

Error : Undefined symbol: '__declspec(dllimport) _pthread_mutex_lock (__imp__pthread_mutex_lock)'
referenced from '_thread_function' in pthread_ex.c:12
referenced from '_main' in pthread_ex.c:31
pthread_ex.c line 12

 

2) I added pthread.c to the project (Project -> Add files). Then I got this error, followed by many errors relating to undefined data types, etc.:

 

Error : the file 'timeb.h' cannot be opened
(included from:
private.c:55
pthread.c:44)
ptw32_relmillisecs.c line 43 #include timeb.h>

 

3) So, I added timeb.h and cdefs.h from www.koders.com, and put these files in the 'sys' folder. The syntax errors relating to time structures remained, e.g.

 

Error : ';' expected
(included from:
private.c:55
pthread.c:44)
ptw32_relmillisecs.c line 50 const int64_t NANOSEC_PER_MILLISEC = 1000000;

 

Error : expression syntax error
(included from:
private.c:55
pthread.c:44)
ptw32_relmillisecs.c line 51 const int64_t MILLISEC_PER_SEC = 1000;

 

Error : expression syntax error
(included from:
private.c:55
pthread.c:44)
ptw32_relmillisecs.c line 52 DWORD milliseconds;

 


********************************************************************************
So, I'd be extremely grateful if anyone could shed some light on what's going on here for me. Are there more files I need to add? Have I accessed the pthreads library inappropriately? Thank you for your consideration--

 

Best,
Matt

Outcomes