From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,fdd183ed896320dd X-Google-Attributes: gidfee84,public From: denham@denham.zk3.dec.com (Jeffrey M. Denham) Subject: Re: BookReader threads example crashes Date: 1995/12/19 Message-ID: <4b7g3k$92h@zk2nws.zko.dec.com>#1/1 X-Deja-AN: 122382577 distribution: world references: <4b2q2j$i1l@harbinger.cc.monash.edu.au> organization: Digital Equipment Corporation reply-to: denham@zk3.dec.com (Jeffrey M. Denham) newsgroups: comp.unix.osf.osf1 In article <4b2q2j$i1l@harbinger.cc.monash.edu.au>, jvf@aurora.cc.monash.edu.au (J Frankland) writes: >The threads programming example in the Guide to DECthreads (accessible >by the bookreader) which conducts a prime number search, crashes. >It is Example 5-1. After compiling with the -lpthreads link flag, and >running it, it Seg Faults before it get to the main() function. You're building the programs incorrectly. The flag is -threads, not -lpthreads etc. cc -o prog proc.c -lwhatever1 -lwhatever2 -threads The -threads switch insures the proper ordering of the other libraries specified with the libraries required for running threads programs. Build with just -lpthreads leaves out a few vital libraries. The correct hand-crafted link would look like this: cc -o prog prog.c -lwhatever1 -lwhatever2 -lpthreads -lmach -lc_r libmach is the library used by the threads library to Mach threads stuff with the kernel. libc_r is the thread-safe reentrant C runtime library. NOTE: with V4.0 of Digital UNIX, due early next year, building threads programs will change slightly. To build "legacy" threaded application (ones based on 1003.1c/D4, as in V3.2C and below): cc -o prog prog.c -threads To build "new" threaded applications based on the final pthreads standard (1003.1c/D10): cc -o prog prog.c -pthread Note also that libc_r will go away. Instead, the only and only libc is now thread safe. Hope this is off some help to you. -- ----------------------------------------------------------------------------- Jeff Denham, Unix Software Group, Digital Equipment Corporation email: denham@zk3.dec.com, voice: (603) 881-0057