Hi David - I've been using pthreads with mingw-w64 with good success, so we ought to be able to get this sorted out.
On Wed, Oct 27, 2010 at 10:26 PM, David Cleaver <[email protected]> wrote: > Hello everyone, > > I've recently decided to learn pthreads. (As an aside, may I recommend that you try out the std::thread facilities in the new c++0x standard? Experimental support for this works in the linux (and other posix?) version of gcc, and I can give you some manual patches to get it working with mingw. I like std::thread so far -- it seems quite sensible, and the interface follows the modern c++ idioms. Quite cool, in my opinion.) > I've just finished writing my first > pthreads program, and have been able to fix most of the problems that gcc > reported to me. However, I am now getting "undefined reference" errors and am > not sure why. Can someone help me diagnose this issue? I am using Windows XP > 64-bit, I am using 64-bit windows 7, and it would surprise me if 7 vs. xp is the issue here. > I am using Ozkan's toolchain (an old one from 2010-01-23), I am using a newer one of his builds: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/sezero_4.5_20101002/mingw-w64-bin_x86_64-mingw_20101002_4.5_sezero.zip/download Perhaps the older build is the issue -- he might know. > and I am > using the files from pthreads-20100604.zip. Note, when I unzipped the above download, it didn't come with pthreads quite ready to go. Rather, it came with the file pthreads-w64.zip in its top-level directory. Unzipping pthreads-w64.zip (in that spot) added working pthreads to my mingw-w54 installation. At least I am using a pthreads version that was delivered with -- and is presumably consistent with -- my gcc version. > (I do not use -pthread because that > gives another error, so that's why I'm using -lpthread.) Here are the errors > that I am getting: > > C:\dir>gcc -o xprp6_4_128.exe sprp6.c -lgmp -lpthread > C:\Temp\cciUpjdJ.o:sprp6.c:(.text+0xabc): undefined reference to > `pthread_mutex_trylock' > C:\Temp\cciUpjdJ.o:sprp6.c:(.text+0xb30): undefined reference to > `pthread_mutex_unlock' > ... My copy of pthread.h contains, for example, the line: PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); and when I link with -lpthread that symbol 9as well as all the others) resolves correctly. I assume that these symbols are defined in: .\mingw64\x86_64-w64-mingw32\lib\libpthread.a but I really don't know. (They're defined somewhere.) I also have a file: .\mingw64\bin\pthreadGC2-w64.dll I don't really know what role it plays, or whether I am using it. > Does anyone know what I might be doing wrong or how I can fix the above? > Thank > you for your time. I have no idea what your specific problem is. A mechanical way to try to fix your problem would be to upgrade to a clean install of the version I'm using -- it works for me -- but that might be overkill. > -David C. Good luck. K. Frank ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
