a problem about standard math function.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
printf("%f\n", cos(30) );
return EXIT_SUCCESS;
}

when compile these code,the IDE printed:

"acos.o: In function main': acos.o(.text+0x2a): undefined reference to _Sin’ "

Should I include other *.h into this file or indicate some additional libs at compile time ??

Thanks anywhere.

\

hcchen@ipp.ac.cn
Hichun Chen

You need to link with the math library. Add a -lm to the end of your linker
command line.

chris


Hichun Chen <hcchen@mail.ipp.ac.cn> wrote:

#include <stdlib.h
#include <stdio.h
#include <math.h
int main(int argc, char *argv[])
{
printf("%f\n", cos(30) );
return EXIT_SUCCESS;
}

when compile these code,the IDE printed:

"acos.o: In function main': acos.o(.text+0x2a): undefined reference to _Sin’ "

Should I include other *.h into this file or indicate some additional libs at compile time ??

Thanks anywhere.

\

hcchen@ipp.ac.cn
Hichun Chen
\


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/