sinf compiler error I don't understand (corrected)
hennebry at web.cs.ndsu.nodak.edu
Fri Apr 1 22:55:48 UTC 2011
On Fri, 1 Apr 2011, les wrote:
> On Fri, 2011-04-01 at 15:29 -0700, les wrote:
>> Here is the smallest sample I have been working with to show the current
>> #include <math.h>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <string.h>
>> long double temp;
>> printf ("M_PI=%e\n",M_PI);
>> printf ("sin 90 = %e\n",sinf(M_PI/2));
>> // the following line won't compile for temp
>> // regardless of how temp is declared (float, double, long double)
>> // printf ("sin 90 = %e\n",sinf(temp));
>> Clearly sinf is recognized, and compiles and runs. It returns 1.000 as
>> expected for M_PI/2. But the line that is commented out will not
>> If you can see the issue here, please let me know.
> missing command and error message:
> gcc -ggdb mathck.c
> /tmp/ccTdnf1Z.o: In function `main':
> /home/lesh/Code/C/arb_wav_file/mathck.c:14: undefined reference to
> collect2: ld returned 1 exit status
It did compile.
It just didn't link.
You are missing -lm .
In the first use,
perhaps the compiler recognized sinf(M_PI/2)
and replaced it with a constant.
In that case, no reference would be made.
Michael hennebry at web.cs.ndsu.NoDak.edu
"Pessimist: The glass is half empty.
Optimist: The glass is half full.
Engineer: The glass is twice as big as it needs to be."
More information about the users