Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » undefined reference to `sin'
undefined reference to `sin' [message #1853449] Sat, 02 July 2022 12:30 Go to next message
Eclipse UserFriend
Hello,
I think this is just a little problem:
I try to calculate a sinus value.
The relevant code is:
#include <math.h>
...
double angle, clearance;
....
clearance = sin(angle*M_PI/180.)*5.0;


here I get a linker error:
undefined reference to `sin'
What may be the problem?
Thanks a lot in advance.
Kurt

[Updated on: Sat, 02 July 2022 12:31] by Moderator

Re: undefined reference to `sin' [message #1853458 is a reply to message #1853449] Sat, 02 July 2022 14:45 Go to previous messageGo to next message
Eclipse UserFriend
You did tell the compiler how the sine function can be called, by including the header file.

Obviously you did not tell the linker to add the math library (-lm on linker command line).
Re: undefined reference to `sin' [message #1853463 is a reply to message #1853458] Sun, 03 July 2022 05:46 Go to previous message
Eclipse UserFriend
Hi Tauno Voipio,
thanks for your answer. IT was very helpful.
Now it works perfect.
Previous Topic:Whats the state of CMake Build Support ?
Next Topic:Missing wiringpi lib
Goto Forum:
  


Current Time: Mon Jul 07 21:33:52 EDT 2025

Powered by FUDForum. Page generated in 0.24022 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top