public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem using math library
@ 2003-12-17 18:24 Tom Tran
  2003-12-17 18:27 ` bjorn rohde jensen
  2003-12-17 18:32 ` Bharathi S
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Tran @ 2003-12-17 18:24 UTC (permalink / raw)
  To: gcc-help

Hi,
I have problem using function in math.h.  gcc gives undefined reference
Here is a sample of my tstpow.c program:

#include <math.h>

int main()
{
   double d;

   d = pow(2.0, 3.0);
  return 0;
}

I compiled the program with:
    gcc tstpow.c

gcc gave this error:
   undefined reference pow

I tried other functions s.a. sqrt(), sin(), etc.  Same problem.
Other header files (s.a. <stdio.h> <string.h> <stdlib.h> work fine.

Please help.

Tom Tran
tom.tran@noaa.gov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem using math library
  2003-12-17 18:24 Problem using math library Tom Tran
@ 2003-12-17 18:27 ` bjorn rohde jensen
  2003-12-17 18:32 ` Bharathi S
  1 sibling, 0 replies; 4+ messages in thread
From: bjorn rohde jensen @ 2003-12-17 18:27 UTC (permalink / raw)
  To: Tom Tran; +Cc: gcc-help

Hi there,

  The math library is not linked against by default, add -lm
at link time to include the math library in link.

Yours sincerely,

Bjorn

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem using math library
  2003-12-17 18:24 Problem using math library Tom Tran
  2003-12-17 18:27 ` bjorn rohde jensen
@ 2003-12-17 18:32 ` Bharathi S
  2003-12-18 19:31   ` Bootstrap compiler IRIX 6.2 Ananda Bhattacharya
  1 sibling, 1 reply; 4+ messages in thread
From: Bharathi S @ 2003-12-17 18:32 UTC (permalink / raw)
  To: Tom Tran; +Cc: gcc-help

On Wed, 17 Dec 2003, Tom Tran wrote:

> gcc gave this error: undefined reference pow

> I tried other functions s.a. sqrt(), sin(), etc.  Same problem.
> Other header files (s.a. <stdio.h> <string.h> <stdlib.h> work fine.

Math library will not be linked by default. Link it by -lm option.

gcc myprg.c -lm

Bye :)
-- 
Bharathi S, IndLinuX Team,   (__)
DON Lab,    TeNeT Group,     oo )
IIT-Madras, Chennai-INDIA.   (_/\ 

Known is drop, Unknown is OCEAN.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Bootstrap compiler IRIX 6.2
  2003-12-17 18:32 ` Bharathi S
@ 2003-12-18 19:31   ` Ananda Bhattacharya
  0 siblings, 0 replies; 4+ messages in thread
From: Ananda Bhattacharya @ 2003-12-18 19:31 UTC (permalink / raw)
  To: gcc-help


	Hi Y'all, 
	
	I have run into a lil problem. I need to compile gcc 
on an IRIX 6.2 ( yes I have one of those ) and I don't have 
a compiler on that machine. So I was wondering if anyone has 
a bootstrap gcc for IRIX 6.2 it would be great. Otherwise 
you can point me in the direction that would be great.
thanks 
&
Happy Holidays
	Anand 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-12-18 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-17 18:24 Problem using math library Tom Tran
2003-12-17 18:27 ` bjorn rohde jensen
2003-12-17 18:32 ` Bharathi S
2003-12-18 19:31   ` Bootstrap compiler IRIX 6.2 Ananda Bhattacharya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).