The transendental stuff is not in the default libraries your programs are linked with
under gcc.  You must specify linkage with that library.  I beleive the library is 
called
libm.a and libm.so if I'm not mistaken.  You would specify linkage with one of those by
using the flag "-lm".  The "-l" means to link with, and a name starting with lib and 
ending
with .a or .so is assumed, so you need only specify the unique part of the library 
name, in
this case the "m".  For example, libsoemthing.a becomes "-lsomething".

gcc test.c -o test.o -lm

For information on gcc, look at "man gcc", "info gcc", and look in the documentation
tree "/usr/doc/gcc-xxxxxx" or "/usr/doc/egcs-xxxxxxxx".  The "xxxxxxx" replaces the
version number.  Your system may have either real gcc or the newer egcs hybrid.

On Sun, Nov 21, 1999 at 02:24:50PM +0800, G.B.Zhou wrote:
> Dear Sir,
> 
> I  just read your book(Red Hat Linux unleashed, Second Edition) and I 'm not 
>familiar with Linux operating system.   Today I write a very simple program with C 
>language, but it unsucessed when I compile it. The program script is at following:
> 
> #include <stdio.h>
> #include <math.h>
> main()
> {
>       int i;
>       double x;
>       for(i=0;i<5;i++)  {
>               x=double(i);
>               x=sin(x);
>               printf( "sin(%d)=%f\t",i,x);
>       }
> }
> 
> and the compiler's information is: /tmp/ccBMA1Cj.o: In function 'main':
>                                                   /tmp/ccBMA1Cj.o(.text+0x48): 
>undefined reference to 'sin'
>                                                collect2: ld return 1 exist status.
> Could you tell me why?  By the way, could you tell me how to get documents of gcc 
>compiler programmer's guide ?
> 
> Thank you!
>       
> 
>             G.B.Zhou
>             [EMAIL PROTECTED]
> 
> 
> -- 
> To unsubscribe:
> mail -s unsubscribe [EMAIL PROTECTED] < /dev/null
> 

-- 
J. Scott Kasten

jsk AT tetracon-eng DOT net

"That wasn't an attack.  It was preemptive retaliation!"

-- 
To unsubscribe:
mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to