Math.h functions...why is the compiler/linker drawing a blank?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all. I'm trying to use a sin() function. I've #included both math.h and stdlib.h, but my code won't build:

   

"main.c:37: undefined reference to `sin' "

   

I say won't build, because if I issue a complie command on the main.c code alone, it works just fine. What gives?

   

 

   

P.S. Yes, I know the argument and resultant are both doubles, that's not the problem.

0 Likes
8 Replies
Anonymous
Not applicable

BTW If it matters, I'm using a PSoC 5 in the form of a Cy8kit050 dev board.

0 Likes
Anonymous
Not applicable

It gets even more weird...I found that if I manually type in an argument to sin, the compiler takes it, but if I even so much as assign the same number to another double variable, the compiler (ARM gcc 4.4.1) gets angry.

   

E.g.:

   

foo = sin(1.234567); => Compiler happy

   

************************************************

   

doo = 1.234567;

   

foo = sin(doo); => Compiler unhappy!

   

***********************************************

   

What is up with this?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, this should be outlined better, I have suffered from the same error until someone else helped me out. have a look at this http://www.cypress.com/?id=4&rID=42838 and follow the instructions

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Bob, I'd buy you a beer if you weren't 3,000 miles away in Der Deutschland. Danke Schoen!!!!!

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Got you!!!

   

I am currently in Silicon Valley having visited Cypress. Where are you, where's my beer??? (very broad smile)

   

Bob

0 Likes
Anonymous
Not applicable

Bob: if you ever visit the Cleveland area, your beer is on me. We in the Midwest have a lot of really good microbreweries. Enjoy sunny Norcal. If you get a chance, visit one of the open space areas to the West of Sunnyvale/SJ. I recommend Pichetti Ranch. It's some beautiful country!

0 Likes
Anonymous
Not applicable

Thank you bob

   

As you said cypress should have outlined this well.even cypress should improve it's search algorithm

   

I had tried to find on this issue on cypress search but all effort went viens.

   

This post is pointed out by google.

0 Likes
Anonymous
Not applicable

Thanks!

0 Likes