Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » undefined reference to `sin'
undefined reference to `sin' [message #1853449] Sat, 02 July 2022 16:30 Go to next message
Kurt Struevy is currently offline Kurt StruevyFriend
Messages: 45
Registered: May 2016
Member
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 16:31]

Report message to a moderator

Re: undefined reference to `sin' [message #1853458 is a reply to message #1853449] Sat, 02 July 2022 18:45 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
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).


--

Tauno Voipio
Re: undefined reference to `sin' [message #1853463 is a reply to message #1853458] Sun, 03 July 2022 09:46 Go to previous message
Kurt Struevy is currently offline Kurt StruevyFriend
Messages: 45
Registered: May 2016
Member
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: Thu Apr 25 20:54:14 GMT 2024

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

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

Back to the top