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
pittbull wrote:
Hi,
The Pthreads lib you try to use seems to be made for MS Visual C++.
The '__declspec(dllimport)' is a MS-specific extensions to the C language.
I don't think there's a CW version of Pthreads, so you must port it yourself (Can't be that much difficult).
Anyway, Pthreads needs an underlying operating system that supports
native threading (But I think you already know that)...
Cheers,
-> pittbull