gcc with math library

saurabh verma saurabh.verma@codito.com
Tue Jun 7 05:48:00 GMT 2005


On Tue, 2005-06-07 at 00:13 -0300, Raphael Fonseca wrote:
> When I try to compile with gcc -otest test.c         it  caused the 
> following error message:
> 
> /home/raphael/tmp/ccUXVGLx.o(.text+0x2c): In function `main':
> : undefined reference to `sin'
> collect2: ld returned 1 exit status

gcc -o test test.c -lm should work

You need to tell the linker to use the math library, hence the -lm flag

regards
saurabh




More information about the Gcc-help mailing list