EmbDev.net

Forum: ARM programming with GCC/GNU tools undefined reference for sin, cos etc.


Author: Bhagat Rajawat (bhagats)
Posted on:

Rate this post
0 useful
not useful
Hi all !

I'm getting "undefined reference to sin" for a simple program:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main ()
{
double a = 40.5;
double b = sin (a);
//printf("%f",b);
return 0;
}

The compiler is : arm-linux-gnueabi-gcc

Thanks in advance.

Author: Klaus Wachtler (mfgkw)
Posted on:

Rate this post
0 useful
not useful
Perhaps the link option -lm helps?

Author: Bhagat Rajawat (bhagats)
Posted on:

Rate this post
0 useful
not useful
Thanks a lot sir, It compiled straight away with that option. I was 
trying it for 2 days.

Author: alex (Guest)
Posted on:

Rate this post
0 useful
not useful
hello !
I have the same problem, but I have just started to program with C and I 
have not undestood your answer, insert -lm...

what I must do to compilate good my program ?

sorry for my bad english !!!

thank you

Author: Klaus Wachtler (mfgkw)
Posted on:

Rate this post
0 useful
not useful
That depends on how you build your program (which IDE or a makefile?).

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.