From owner-freebsd-threads@FreeBSD.ORG Sat Jun 16 10:35:00 2007 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 886E016A469 for ; Sat, 16 Jun 2007 10:35:00 +0000 (UTC) (envelope-from frank@pinky.sax.de) Received: from pinky.frank-behrens.de (pinky.frank-behrens.de [82.139.199.24]) by mx1.freebsd.org (Postfix) with ESMTP id CB30A13C4C1 for ; Sat, 16 Jun 2007 10:34:59 +0000 (UTC) (envelope-from frank@pinky.sax.de) Received: from [192.168.20.32] (sun.behrens [192.168.20.32]) by pinky.frank-behrens.de (8.14.1/8.14.1) with ESMTP-MSA id l5GAYhAm063235 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=NO); Sat, 16 Jun 2007 12:34:43 +0200 (CEST) (envelope-from frank@pinky.sax.de) Message-Id: <200706161034.l5GAYhAm063235@pinky.frank-behrens.de> From: "Frank Behrens" To: Gergely CZUCZY Date: Sat, 16 Jun 2007 12:34:42 +0200 MIME-Version: 1.0 Priority: normal In-reply-to: <20070615171857.GA89955@harmless.hu> References: <200706151701.l5FH1KuJ047078@pinky.frank-behrens.de> X-mailer: Pegasus Mail for Windows (4.31, DE v4.31 R1) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Hashcash: 1:24:070616:freebsd-threads@freebsd.org::bgPZBsZ4RCqKSzsp:0000000pCT6 X-Hashcash: 1:24:070616:phoemix@harmless.hu::544gpygsiv1ldcXD:Nc3L Cc: freebsd-threads@freebsd.org Subject: Re: Linking to pthread library: undefined reference X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jun 2007 10:35:00 -0000 Gergely CZUCZY wrote on 15 Jun 2007 19:18: > On Fri, Jun 15, 2007 at 07:01:19PM +0200, Frank Behrens wrote: > > I try to link an milter (sendmail mail filter) test application and get an error I do not > > understand. I use FreeBSD 6.2-STABLE-200705211513 with an userland from May-03. > > In my Makefile I have: > > CFLAGS+= -I/usr/local/include -std=c99 -pthread -v > > LDADD+= -L/usr/local/lib -lmilter > > > > This gives linker command: > > cc -O2 -pipe -fno-strict-aliasing -march=pentium4 -I/usr/local/include -std=c99 -pthread -v -g - > > DDEBUG=1 -O1 -fno-omit-frame-pointer -Wsystem-headers -Wall -Wno-format-y2k -W - > > Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn- > > type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter - > > Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -o fmilter fmilter.o - > > L/usr/local/lib -lmilter > > Using built-in specs. > > Configured with: FreeBSD/i386 system compiler > > Thread model: posix > > gcc version 3.4.6 [FreeBSD] 20060305 > > /usr/bin/ld -V -dynamic-linker /libexec/ld-elf.so.1 -o fmilter /usr/lib/crt1.o /usr/lib/crti.o > > /usr/lib/crtbegin.o -L/usr/local/lib -L/usr/lib fmilter.o -lmilter -lgcc -lpthread -lc -lgcc > I don't think this is the problem here, but you should link against -pthread, and > not -lpthread. pthread is just an API here, while -pthread refers to the > system-default threading library (with a pthread interface). The -lpthread was added automatically, I used in CFLAGS -pthread only. > > /usr/lib/crtend.o /usr/lib/crtn.o > > GNU ld version 2.15 [FreeBSD] 2004-05-23 > > Supported emulations: > > elf_i386_fbsd > > /usr/lib/libmilter.so: undefined reference to `pthread_detach' > > > > In my opinion the symbol should be found in > > /usr/lib/libpthread.so@ -> /lib/libpthread.so.2 > > > > When I look into the libraries I see > > > objdump -T /usr/lib/libmilter.so | fgrep detach > > 00000000 D *UND* 00000000 pthread_detach > > > > > objdump -T /usr/lib/libpthread.so | fgrep pthread_detach > > 000077d4 w DF .text 000003a4 LIBTHREAD_1_0 pthread_detach > > 000077d4 g DF .text 000003a4 LIBTHREAD_1_0 _pthread_detach What does LIBPTHREAD_1_0 mean? Regards, Frank -- Frank Behrens, Osterwieck, Germany PGP-key 0x5B7C47ED on public servers available.