New guy to the yellowdog-general mailing list (with two questions)

Michael Jeffrey Tucker yellowdog-general@lists.terrasoftsolutions.com
Fri Feb 27 21:10:01 2004


Hi Steve,

  How are you compiling your program? Make sure that you are instructing
gcc to link against the math library (libm). If I had a single source file
that I was trying to compile, I would use:

gcc -lm sourcefile.c -o executable

The -lm will tell gcc to use the lib`m` library.

Mike

> Second issue, I'm trying to compile a program that
> uses the sqrt() function for a C class I'm taking.  I
> get the following error when I compile.
> ]
> /tmp/cc1D4spp.o(.text+0xa0):  In function 'main':
> : undefined refrence to 'sqrt'
> /tmp/cc1D4spp.o(.text+0xa0):  In function 'main':
> : relocation truncated to fit: R_PPC_REL24 sqrt
> collect2: ld returned 1 exit status
>
> The only way I can sqrt to behave is if I type:
> double sqrt(sqrt x);
>
> on a line all by itself, but that doesnt help me with
> what I'm trying to do.