Solved

sin()  and cos() in math.h

Posted on 2004-09-26
2
1,232 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
Comment Utility
try this when you compile

    gcc -lm yourfile.c


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

Expert Comment

by:hongjun
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now