This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: FW: GCC 2.95.3 Cross-Compler : Error "undefined reference to `pth read_create'"
- To: Rocha Iran-QIR001 <Iran dot Rocha at motorola dot com>
- Subject: Re: FW: GCC 2.95.3 Cross-Compler : Error "undefined reference to `pth read_create'"
- From: Zack Weinberg <zack at codesourcery dot com>
- Date: Fri, 28 Sep 2001 11:06:55 -0700
- Cc: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- References: <1FA6C7249817D4119B9800D0B73E99A605118CF4@il02exm27.comm.mot.com>
On Fri, Sep 28, 2001 at 12:32:46PM -0500, Rocha Iran-QIR001 wrote:
> Hello,
>
> We found out that GCC is not parsing correctly the input
> parameters. See the e-mail below for more info. We thought that we
> were making something wrong and we first submitted this problem to
> gcc-help. Since we found out that the bug was the reason of the
> problem, we are forwarding the report to gcc-bugs.
...
> mach(kuser)[314]> gcc -bi686-pc-linux-gnu -lpthread main.c
> /var/tmp/ccy0gerj.o: In function `main':
> /var/tmp/ccy0gerj.o(.text+0x1d): undefined reference to `pthread_create'
> collect2: ld returned 1 exit status
>
> The case above fails because "-lpthread" is the third parameter to
> be passed. Now, if we move it to the tail of the command line ...
>
> mach(kuser)[315]> gcc -bi686-pc-linux-gnu main.c -lpthread
> mach(kuser)[316]> ls -l a.out
> -rwxr-xr-x 1 kuser suin 1175107 Sep 28 11:43 a.out*
>From the GCC manual, "Link Options":
`-lLIBRARY'
Search the library named LIBRARY when linking.
It makes a difference where in the command you write this option;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the linker searches processes libraries and object files in the
order they are specified. Thus, `foo.o -lz bar.o' searches
library `z' after file `foo.o' but before `bar.o'. If `bar.o'
refers to functions in `z', those functions may not be loaded.
zw