From owner-freebsd-stable Thu Dec 19 17:35:41 2002 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2368D37B401 for ; Thu, 19 Dec 2002 17:35:39 -0800 (PST) Received: from tiamat.ipv6.hackerheaven.org (ipv6.hackerheaven.org [80.126.0.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F64043EDC for ; Thu, 19 Dec 2002 17:35:37 -0800 (PST) (envelope-from coolvibe@hackerheaven.org) Received: from tiamat.ipv6.hackerheaven.org (localhost.ipv6.hackerheaven.org [127.0.0.1]) by tiamat.ipv6.hackerheaven.org (8.12.6/8.12.6) with ESMTP id gBK1Yk51075605 for ; Fri, 20 Dec 2002 02:34:46 +0100 (CET) (envelope-from coolvibe@tiamat.ipv6.hackerheaven.org) Received: (from coolvibe@localhost) by tiamat.ipv6.hackerheaven.org (8.12.6/8.12.6/Submit) id gBK1Yjqi075604 for freebsd-stable@freebsd.org; Fri, 20 Dec 2002 02:34:45 +0100 (CET) Date: Fri, 20 Dec 2002 02:34:45 +0100 From: Emiel Kollof To: freebsd-stable@freebsd.org Subject: pthread woes Message-ID: <20021220013445.GA75547@hackerheaven.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: Mutt 1.3.23i (2001-10-09) X-Editor: Vim http://www.vim.org/ X-Info: http://www.hackerheaven.org/ X-Info2: http://www.cmdline.org/ X-Info3: http://www.coolvibe.org/ X-message-flag: Out of cheese error! User-Agent: Mutt/1.5.1i Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi folks, I have a problem with compiling stuff that uses POSIX threads. I used the following snippet of code to test: --- test.c --- #include #include #define NUM_THREADS 5 void *PrintHello(void *threadid) { printf("\n%d: Hello World!\n", threadid); pthread_exit(NULL); } int main() { pthread_t threads[NUM_THREADS]; int rc, t; for(t=0;t < NUM_THREADS;t++){ printf("Creating thread %d\n", t); rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t); if (rc){ printf("ERROR; return code from pthread_create() is %d\n", rc); exit(-1); } } pthread_exit(NULL); } --- end test.c --- When I compile it, I get the following errors: % gcc test.c -o test.c /tmp/ccF3QI1k.o: In function `PrintHello': /tmp/ccF3QI1k.o(.text+0x20): undefined reference to `pthread_exit' /tmp/ccF3QI1k.o: In function `main': /tmp/ccF3QI1k.o(.text+0x76): undefined reference to `pthread_create' /tmp/ccF3QI1k.o(.text+0xba): undefined reference to `pthread_exit' It compiles fine when I use -lc_r. This also breaks a lot of ports. What's going on? Cheers, Emiel -- The man who sets out to carry a cat by its tail learns something that will always be useful and which never will grow dim or doubtful. -- Mark Twain. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message