Hi I am trying to compile a small POSIX threads test program and it fails on my gentoo system. $ cat thread.c #include <stdio.h> #include <pthread.h> void * doit(void *); int main(void) { pthread_t kid; kid = pthread_create(&kid, NULL, doit, NULL); } void * doit(void * arg) { printf("Hello World\n"); return NULL; } $ gcc thread.c thread -lpthread collect2: ld terminated with signal 11 [Segmentation fault], core dumped thread(.rodata+0x0): multiple definition of `_fp_hw' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o(.rodata+0x0): first defined here thread(.data+0x4): In function `__data_start': : multiple definition of `__dso_handle' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/crtbegin.o(.data+0x0): first defined here thread(.init+0x0): In function `_init': /var/tmp/portage/glibc-2.3.2-r3/work/glibc-2.3.2/buildhere/csu/crti.S:35: multiple definition of `_init' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crti.o(.init+0x0):/var/tmp/portage/glibc-2.3.2-r9/work/glibc-2.3.2/buildhere/csu/crti.S:12: first defined here thread(.text+0xf0): In function `doit': : multiple definition of `doit' /tmp/ccscFn0n.o(.text+0x38): first defined here thread(.text+0x0): In function `_start': : multiple definition of `_start' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o(.text+0x0): first defined here thread(.text+0xb8): In function `main': : multiple definition of `main' /tmp/ccscFn0n.o(.text+0x0): first defined here thread(.fini+0x0): In function `_fini': /var/tmp/portage/glibc-2.3.2-r3/work/glibc-2.3.2/buildhere/csu/crti.S:51: multiple definition of `_fini' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crti.o(.fini+0x0): first defined here thread(.got+0x0): multiple definition of `_GLOBAL_OFFSET_TABLE_' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o(.got.plt+0x0): first defined here thread(.rodata+0x4): multiple definition of `_IO_stdin_used' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o(.rodata+0x4): first defined here thread(.data+0x0): In function `__data_start': : multiple definition of `__data_start' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o(.data+0x0): first defined here /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o(.dynamic+0x0): multiple definition of `_DYNAMIC' thread(.dynamic+0x0): first defined here It does the same with -pthread too. Strangely enough on another gentoo system seems work fine. Any ideeas ? Reproducible: Always Steps to Reproduce: compile a program with -pthread Actual Results: ld dumped core Expected Results: should compile the program with no error Portage 2.0.50-r1 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r9, 2.6.3) ================================================================= System uname: 2.6.3 i686 Intel(R) Pentium(R) 4 CPU 2.00GHz Gentoo Base System version 1.4.3.13 Autoconf: sys-devel/autoconf-2.58-r1 Automake: sys-devel/automake-1.7.7 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-march=i686 -O2 -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.1/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/share/config /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /var/qmail/alias /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-march=i686 -O2 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs buildpkg ccache sandbox" GENTOO_MIRRORS="ftp://ftp.lug.ro/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.de.gentoo.org/gentoo-portage" USE="X aalib alsa apache2 apm avi berkdb crypt dvd encode foomaticdb gdbm gif gpm gtk gtk2 imlib java jpeg libg++ libwww mad mikmod mmx motif mozilla mpeg mysql ncurses nls oggvorbis opengl pam pdflib perl png python quicktime readline sdl slang spell sse ssl tcltk tcpd truetype x86 xml2 xmms xv zlib"
You're just typing something wrong. Most likely you're typing: gcc thread -o thread.c -lpthread instead of gcc thread.c -o thread -lpthread Please don't post bug reports for stuff like this. The forums are a good place for help for problems.
You are right that I typed wrong this must be my stupid day... Sorry to take your time (I have even pasted the command I used to type it is "gcc thread.c thread -pthread" and I already had a "thread" compiled from some time ago). I never reported such a stupid bug before (you can search the bugtracker for my previously reported bugs). Sorry again.