Date: 19 Dec 2002 20:51:02 -0500 From: Joe Marcus Clarke <marcus@marcuscom.com> To: Emiel Kollof <coolvibe@hackerheaven.org> Cc: freebsd-stable@FreeBSD.ORG Subject: Re: pthread woes Message-ID: <1040349062.2280.5.camel@shumai.marcuscom.com> In-Reply-To: <20021220013445.GA75547@hackerheaven.org> References: <20021220013445.GA75547@hackerheaven.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Thu, 2002-12-19 at 20:34, Emiel Kollof wrote:
> 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?
On 4.x, you need to compile threaded applications with the -pthread
flag. On 5.x, you should use -lc_r. When linking with pthread or
libc_r, you should not also link with libc as this has been known to
cause problems with multi-threaded applications.
What ports are broken because of this? Any port which can't find
-pthread or -lc_r on its own should have ${PTHREAD_LIBS} added to its
LIBS configure argument. With that, there are also some thread-related
CFLAGS that should be added. These are defined by the ports system as
${PTHREAD_CFLAGS}.
Joe
>
> Cheers,
> Emiel
--
PGP Key : http://www.marcuscom.com/pgp.asc
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQA+AneGb2iPiv4Uz4cRAlLqAKCiAWEK2q6v1DAHnPXvLVy0+8g8mACeNRld
YixOa02RiARKT+eapSVF3RE=
=JMK1
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1040349062.2280.5.camel>
