Subj : Re: Where to download a pthread library To : comp.programming.threads From : David Butenhof Date : Wed Mar 30 2005 12:41 pm David Schwartz wrote: > The '-lpthread' flag is not a convention or standard at all. Technically, this statement is not quite correct. The POSIX/XCU standard specifies that with the c89 or c99 commmand, the formal and portable way to build a threaded program is indeed with exactly and only "-lpthread". Of course, on some systems that might need to do more than find a "libpthread.so" -- or even something entirely different. But that's up to the compiler/linker/driver, not the user. ON THE OTHER HAND... hardly anyone uses the 'c89' or 'c99' commands. You use 'cc', or 'cxx', or 'aCC', or 'gcc'... or whatever. And in that case as David says your fate is in the hands of the command gods. (And despite what the standard says, compiler writers don't like the requirement to do something special for a specific "-l" value, and I'd be willing to bet most vendors haven't done it anyway.) > Many > platforms require more than just linking in an additional library, they need > compiler flags (like -D_REENTRANT) as well. The standard is '-pthread' to do > whatever is needed for both the compiler and linker to support pthreads. > FreeBSD was very slow to adopt this standard due to some confusion. -pthread is arguably a reasonably widespread CONVENTION, but definitely not worthy of the term "standard" either in a de jure or de facto sense. It'll work for many versions of gcc across platforms, (but not all), and several vendor compilers. The second most popular is probably "-mt" (e.g., on Solaris). Beyond THAT, you're entirely on your own. -- Dave Butenhof, David.Butenhof@hp.com HP Utility Pricing software, POSIX thread consultant Manageability Solutions Lab (MSL), Hewlett-Packard Company 110 Spit Brook Road, ZK2/3-Q18, Nashua, NH 03062 .