FW: GCC 2.95.3 Cross-Compler : Error "undefined reference to `pth read_create'"

Zack Weinberg zack@codesourcery.com
Fri Sep 28 11:07:00 GMT 2001

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":

     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.


More information about the Gcc-bugs mailing list