This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: undefined references?
- To: Nick Papadonis <npapadon at yahoo dot com>
- Subject: Re: undefined references?
- From: "J. Johnston" <jjohnstn at cygnus dot com>
- Date: Tue, 08 May 2001 16:00:27 -0400
- CC: newlib at sources dot redhat dot com
- Organization: Red Hat Inc.
- References: <m3bsp5nue9.fsf@yahoo.com>
Nick Papadonis wrote:
>
> I'm trying to compile some test code with newlib. I did a unified
> build of newlib,gcc,gas, and ld. Apparently my linker isn't finding
> symbols in my newlib libraries. Anyone have any idea whats happening
> here? Thanks.
>
> - Nick
>
Nick,
Specifying archives to search when linking is position dependent. In your link you have the
libraries specified before the object decks. At the point they are specified, there is nothing to
resolve. When the linker gets to the .o files, it does not go back and search the libraries
previously specified. You should have specified -lc -lm after your last .o file.
-- Jeff J.
> test.c:
> -------
> #include <math.h>
> #include <string.h>
>
> static void _main (void) {
> double d;
>
> d = cosh(20.0);
>
> }
>
> [nick@noop lib]$ m68k-coff-nm libm.a |grep cosh
> w_cosh.o:
> U __ieee754_cosh
> 00000006 T cosh
>
> [nick@noop test2]$ make
> m68k-coff-ld --verbose -lm -lc -T./ram.ld crt0.o test.o -o main
> GNU ld version 2.11.90 (with BFD 2.11.90)
> Supported emulations:
> m68kcoff
> opened script file ./ram.ld
> attempt to open /usr/local/m68k-coff/m68k-coff/lib/libm.a succeeded
> attempt to open /usr/local/m68k-coff/m68k-coff/lib/libc.a succeeded
> attempt to open crt0.o succeeded
> crt0.o
> attempt to open test.o succeeded
> test.o
> test.o: In function `_main':
> /home/nick/build/test2/test.c:17: undefined reference to `cosh'
> make: *** [main] Error 1