what does this error mean ?

raurava's Avatar, Join Date: Jul 2007
Newbie Member
hello all ,
I am new to C programming and trying to learn by working some online tutorials.
I am working on a linux OS ( Ubuntu ) .

so the program is to calculate a table of sine values and I typed in the code pretty much the way it was show in the tutorial, the code is shown below:

				/* Written: Winter 1995	*/
#include < stdio.h>
#include < math.h>

void main()
    int    angle_degree;
    double angle_radian, pi, value;

					/* Print a header */
    printf ("\nCompute a table of the sine function\n\n");

					/* obtain pi once for all */
					/* or just use pi = M_PI, where
					   M_PI is defined in math.h 	*/
    pi = 4.0*atan(1.0);
    printf ( " Value of PI = %f \n\n", pi );

    printf ( " angle     Sine \n" );

    angle_degree=0;			/* initial angle value 		 */
					/* scan over angle 		 */

    while (  angle_degree <= 360 )	/* loop until angle_degree > 360 */
       angle_radian = pi * angle_degree/180.0 ;
       value = sin(angle_radian);
       printf ( " %3d      %f \n ", angle_degree, value );

       angle_degree = angle_degree + 10; /* increment the loop index	 */
When I try to complile the program by typing

$ gcc program_name.c

I get the following error :

/tmp/cciKZE0g.o: In function `main':
sine.c:(.text+0x58): undefined reference to `sin'
collect2: ld returned 1 exit status

what does this mean ?? what should I do ? can any one help ?

thanks ,

Last edited by shabbir; 20Jul2007 at 15:58.. Reason: Code block
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Before you make a query
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Have proper code blocks when you post code snippets in the posts.
DaWei's Avatar, Join Date: Dec 2006
Team Leader
In C, which you are using, sin takes a double as an argument, not a float. Use sinf for floats. In C++, the functions are overloaded, so will work. Refer to your documentation for the functions you use.