|
From: Charles W. <cwi...@us...> - 2011-06-28 05:13:33
|
On 6/27/2011 8:24 AM, Daniel Kovacevic wrote: > I added the "libpthreadGC2.a" lib and the "libpthreadGCE2.a" lib > hoping that they were the missing libraries that pthreads in > semaphore.h was referencing. Yes, they are. But you only want one of them -- probably -lpthreadGC2 (which is what you get with -lpthread). -lpthreadGCE2 is an experimental version that uses C++ exceptions... However, it's too early to be using these versions of pthreads, unless you're a lot more experienced with porting software to win32 than it appears from this thread. > No, I don't know whether or not I need to add more libraries to the > compiler. The Sockets library said that you have to add libwsock32.a > and libws2_32.a; no other libs were mentioned > (http://www.alhem.net/Sockets/tutorial/install.html). Of course, the > instructions were written with the assumption that you are attempting > to compile under cygwin, which I am not. Could that be why the > pthreads lib is missing? Yes and no. On cygwin, pthread functionality is built in to the cygwin runtime, so -lpthread is not needed (even if pthreads ARE used by the application). On mingw, you need to explicitly link in a library that provides the pthread functionality. However, you're missing one big thing: MinGW gcc is not some magic genie that can automatically take a unix program and "make it work" on windows. If the unix program uses POSIX functionality, then it won't compile -- MinGW is *minimal*, it doesn't provide the POSIX stuff that is missing on win32 (*cygwin* does that). MinGW is for compiled apps that only require what win32 provides. You'll need to actually PORT the application to windows. This means stuff as simple as #include <io.h> and <process.h> instead of <unistd.h> (actually, MinGW provides a stuff unistd.h that does this for you, but MSVC doesn't) ...or as complex as ripping out all posix networking code and replacing it with winsock calls. OR ripping out all the unix signal handling code and replacing it with Win32 Message loops. > Is there another pthreads lib I should be using? I retrieved > libwsock32.a and libws2_32.a from the system32 directory, but I wasn't > able to find a "libpthreads.dll" in there. There are two different pthreads packages right now. The current one is shipped with mingw gcc 4.5.2 and is: /mingw/bin/libpthread-2.dll /mingw/lib/libpthread.dll.a /mingw/include/pthread.h /mingw/include/sched.h /mingw/include/semaphore.h That's the one you should be using for now -- NOT the DLLs/libs from the pthreads-w32 website. To make sure our version is installed, do mingw-get install pthreads-w32 The next version of GCC will support the new pthreads packages -- which will be more similar (identical?) to the ones at the pthreads-w32 website. For now, this 'new' version is here: http://mingw.cwilson.fastmail.fm/ but you should wait until mingw gcc-$NEXT is released before using that one. -- Chuck |