undefined reference help

N

none

i have:

#include <math.h>

int main (void)
{
double i = 0.0;
double v = 0.0;

i = cos(v);

return 0;
}


i get 'undefined reference to cos'. it happens with any
function in math.h.

what to do?

btw using rh 8.0 3.2-7 gcc version 3.2

please & thanks!
 
J

Joe Estock

none said:
i have:

#include <math.h>

int main (void)
{
double i = 0.0;
double v = 0.0;

i = cos(v);

return 0;
}


i get 'undefined reference to cos'. it happens with any function in math.h.

what to do?

btw using rh 8.0 3.2-7 gcc version 3.2

please & thanks!
[snip newsfeeds.com appendage]

[OT]
link with -lmath
[/OT]

Joe
 
M

Martin Ambuhl

none wrote:
[...]
i get 'undefined reference to cos'. it happens with any function in math.h.

what to do?

Here's how a civilized human being would do it: check the FAQ before
posting questions. The answer is there.
 
J

Joe Estock

Keith said:
Joe Estock said:
none said:
i have:
#include <math.h>
int main (void)
{
double i = 0.0;
double v = 0.0;
i = cos(v);
return 0;
}
i get 'undefined reference to cos'. it happens with any function in
math.h.
[...]

[OT]
link with -lmath
[/OT]


[OT]
-lm, not -lmath.
C FAQ 14.3 <http://www.eskimo.com/~scs/C-faq/faq.html>
[/OT]

Thanks for the catch Keith. I've been up far too long and I'm running
low on coffee.

Joe
 
N

none

i can take one, but i'll answer this one, i did check the
faq. i clicked on 'all questions' & searched for 'undefined
reference'. i didn't get any hits. thanks to all esp. joe
who got me on the right track. so can't we all get along &
stop wasting space here? ty

Martin said:
none wrote:
[...]
i get 'undefined reference to cos'. it happens with any function in
math.h.

what to do?


Here's how a civilized human being would do it: check the FAQ before
posting questions. The answer is there.
 
M

Martin Ambuhl

none said:
i can take one, but i'll answer this one, i did check the faq. i clicked
on 'all questions' & searched for 'undefined reference'. i didn't get
any hits. thanks to all esp. joe who got me on the right track. so
can't we all get along & stop wasting space here? ty

The biggest space wasters are the folks who post questions already
answered in the FAQ. Buy a mirror.
 
K

Keith Thompson

Martin Ambuhl said:
The biggest space wasters are the folks who post questions already
answered in the FAQ. Buy a mirror.

In the OP's defense, that particular FAQ can be difficult to find if
you don't already know what you're looking for. The question is

I'm trying to do some simple trig, and I am #including <math.h>,
but I keep getting ``undefined: sin'' compilation errors.

A search for "undefined" or "math.h" would have found it, but it's
understandable that someone could miss it. (It usually takes me a
couple of tries to find that one myself, and I already know the
answer.)

I suggest that the only response needed for the original question was

C FAQ 14.3 <http://www.eskimo.com/~scs/C-faq/faq.html>
 
M

Mark McIntyre

i can take one, but i'll answer this one, i did check the
faq. i clicked on 'all questions' & searched for 'undefined
reference'. i didn't get any hits

You needed to search for "undefined" and then you'd have found several
useful sections. Patience is important by the way.
 
J

Joe Wright

Mark said:
You needed to search for "undefined" and then you'd have found several
useful sections. Patience is important by the way.

Dear God. Please give me patience. Now!
 
R

Richard Heathfield

Joe Wright said:
Dear God. Please give me patience. Now!

Uh-oh. You know what happens when you ask God for more patience? He sends
you more children.
 
R

Randy Howard

Richard Heathfield wrote
(in article
Uh-oh. You know what happens when you ask God for more patience? He sends
you more children.

D O E S N O T C O M P U T E
 
R

Richard Bos

Richard Heathfield said:
Joe Wright said:

Uh-oh. You know what happens when you ask God for more patience? He sends
you more children.

That's a good thing, surely? Unless you're out of Andalouse.

Richard
 
M

Mark McIntyre

Uh-oh. You know what happens when you ask God for more patience? He sends
you more children.

You mean, trial by ordeal...

anyway, to get children you need to fork, and thats offtopic here....

gd&r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top