Solved

sin()  and cos() in math.h

Posted on 2004-09-26
2
1,235 Views
Last Modified: 2012-08-13
I'm trying to use sin() and cos() in my program, and I'm always getting error message saying: "undefined reference to 'sin' " or "undefined reference to 'cos' ". I've included math.h. I have also make sure that the functions parameter is of type double.  I'm using Red Hat Linux operating system, and use gcc to compile my program. What seems to be the problem causing this?? Thanks for your help.
0
Comment
Question by:sutejok
  • 2
2 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 125 total points
ID: 12154035
try this when you compile

    gcc -lm yourfile.c


You need to include math library during compilation.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12154099
Thanks for selecting my comment as the answer. But why the grade of "B"? It could have been an A grade since my comment solved your problem directly. Note that a grade A given does not differ from a grade B or C to a questionner. It will not affect your question points value but rather it only affect your grading record. Your grading record will be better if you shows consistent A grading awarding habit.

Please see Tip #11 - Grade quickly and fairly
http://cd-eepages.fateback.com/asking.html

Please explain the reason for the B grade.

hongjun
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question