> 
> I having trouble with linking libraries
> 
> say I have a program called foo.c
> #include <stdio.h>
> #include<math.h>
> 
> main()
> {
> int i;
> float j;
> for(i=1;i<100;++i)
> j=sin(1.0*i,pow(1.0*i,2));
> }
> When creating the executable 
> gcc -o foo foo.c  or egcs -o foo foo.c
> 
> I got the following errors
> /tmp/ccDfH7Hu.o   main:
> /tmp/ccDfH7Hu.o(.text+0x22):undefined reference to 'sin'
> /tmp/ccDfH7Hu.o(.text+0x22):undefined reference to 'pow'

you must link against libm:

gcc -o foo foo.c -lm

but also, sin() only takes one argument, and you are passing it two
arguments.  "man sin".

Brian


> 
> How can I fix this problem ? When I use g++ things work fine.
> Larry<[EMAIL PROTECTED]>
> 
> This message was sent by XFMail
> ----------------------------------
> 
> 
> -- 
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.
> 

-----------------------------------------------------
Brian Feeny (BF304)     [EMAIL PROTECTED]   
318-222-2638 x 109      http://www.shreve.net/~signal      
Network Administrator   ShreveNet Inc. (ASN 11881)            


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to