public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* math.h
@ 2000-01-12  9:16 Tom Filley
  2000-04-01  0:00 ` math.h Tom Filley
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Filley @ 2000-01-12  9:16 UTC (permalink / raw)
  To: gnu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

I recently took up learning C and had a problem 
when trying to compile a program that called the pow() function and the sqrt() 
function. I thought those functions should have been in the math.h header file. 
My programs worked with the Microsoft compiler, but I would prefer 
to write programs for Linux. I have 3 computers with 3 different versions 
of Linux installed, but none of them have the math functions that I need (or 
that I know of at least). I have the versions of gcc that were included with 
Redhat 6.0, Redhat 6.1, and Mandrake 6.0. I was wondering if there is a new 
math.h file that I can download somewhere. If you know, please send me a link to 
it.
 
Thanks much,
        Tom 
Filley
        tafilley@home.com
 

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

* math.h
  2000-01-12  9:16 math.h Tom Filley
@ 2000-04-01  0:00 ` Tom Filley
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Filley @ 2000-04-01  0:00 UTC (permalink / raw)
  To: gnu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

I recently took up learning C and had a problem 
when trying to compile a program that called the pow() function and the sqrt() 
function. I thought those functions should have been in the math.h header file. 
My programs worked with the Microsoft compiler, but I would prefer 
to write programs for Linux. I have 3 computers with 3 different versions 
of Linux installed, but none of them have the math functions that I need (or 
that I know of at least). I have the versions of gcc that were included with 
Redhat 6.0, Redhat 6.1, and Mandrake 6.0. I was wondering if there is a new 
math.h file that I can download somewhere. If you know, please send me a link to 
it.
 
Thanks much,
        Tom 
Filley
        tafilley@home.com
 

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

* Re: math.h
  2005-04-05  9:01 math.h John Poma
@ 2005-04-05  9:21 ` Leopold Palomo-Avellaneda
  0 siblings, 0 replies; 10+ messages in thread
From: Leopold Palomo-Avellaneda @ 2005-04-05  9:21 UTC (permalink / raw)
  To: gcc-help

Maybe I don't understand the question but you need only to add 

#include <math.h>

and link with the -lm

Leo



A Dimarts 05 Abril 2005 11:01, John Poma va escriure:
> Hello,
>
> Please, in which include file may I find the mathematical functions such
> sin, cos, pow, sqrt, etc.
>
> Thanks a lot for your help.
> Best regards.
>
> John Poma

-- 
--
Linux User 152692
Catalonia

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

* math.h
@ 2005-04-05  9:01 John Poma
  2005-04-05  9:21 ` math.h Leopold Palomo-Avellaneda
  0 siblings, 1 reply; 10+ messages in thread
From: John Poma @ 2005-04-05  9:01 UTC (permalink / raw)
  To: gcc-help

Hello,

Please, in which include file may I find the mathematical functions such 
sin, cos, pow, sqrt, etc.

Thanks a lot for your help.
Best regards.

John Poma

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

* Re: math.h
  1999-10-19 22:29 ` math.h Arthur Gold
@ 1999-10-31 13:57   ` Arthur Gold
  0 siblings, 0 replies; 10+ messages in thread
From: Arthur Gold @ 1999-10-31 13:57 UTC (permalink / raw)
  To: help-gcc

"Dennis J. Sylvester" wrote:
> 
> I tried using the sqrt() function with gcc and get an error : undefined
> reference to 'sqrt'.  If I compile with g++ I have no problem.  I get
> the same result when trying to use pow() also.  What am I missing?
> 
> Any help would be appreciated.
> 
> Dennis
Add the option -lm to your command line when you compile.
</rant on>
...and read the FAQs...and the docs...it's all in there...in fact if you
LOOK, this has probably been covered at least twice this week on this
and similar newsgroups...
</rant off>

HTH,
--ag
-- 
Artie Gold, Austin, TX
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
Pet peeve: "its" = belonging or pertaining to "it" | "it's" = "it is"

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

* Re: math.h
  1999-10-19 23:13 ` math.h Maurizio Loreti
@ 1999-10-31 13:57   ` Maurizio Loreti
  0 siblings, 0 replies; 10+ messages in thread
From: Maurizio Loreti @ 1999-10-31 13:57 UTC (permalink / raw)
  To: help-gcc

"Dennis J. Sylvester" <dsylvest@primenet.com> writes:

> I tried using the sqrt() function with gcc and get an error : undefined
> reference to 'sqrt'.

Did you link the math library?  I mean, did you type "-lm", like in

gcc -ansi -pedantic -Wall -o foo foo.c -lm

?`

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Univ. of Padova, Dept. of Physics - Padova, Italy            loreti@pd.infn.it

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

* math.h
  1999-10-19 21:55 math.h Dennis J. Sylvester
  1999-10-19 22:29 ` math.h Arthur Gold
  1999-10-19 23:13 ` math.h Maurizio Loreti
@ 1999-10-31 13:57 ` Dennis J. Sylvester
  2 siblings, 0 replies; 10+ messages in thread
From: Dennis J. Sylvester @ 1999-10-31 13:57 UTC (permalink / raw)
  To: help-gcc

I tried using the sqrt() function with gcc and get an error : undefined
reference to 'sqrt'.  If I compile with g++ I have no problem.  I get
the same result when trying to use pow() also.  What am I missing?

Any help would be appreciated.

Dennis

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

* Re: math.h
  1999-10-19 21:55 math.h Dennis J. Sylvester
  1999-10-19 22:29 ` math.h Arthur Gold
@ 1999-10-19 23:13 ` Maurizio Loreti
  1999-10-31 13:57   ` math.h Maurizio Loreti
  1999-10-31 13:57 ` math.h Dennis J. Sylvester
  2 siblings, 1 reply; 10+ messages in thread
From: Maurizio Loreti @ 1999-10-19 23:13 UTC (permalink / raw)
  To: help-gcc

"Dennis J. Sylvester" <dsylvest@primenet.com> writes:

> I tried using the sqrt() function with gcc and get an error : undefined
> reference to 'sqrt'.

Did you link the math library?  I mean, did you type "-lm", like in

gcc -ansi -pedantic -Wall -o foo foo.c -lm

?`

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Univ. of Padova, Dept. of Physics - Padova, Italy            loreti@pd.infn.it

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

* Re: math.h
  1999-10-19 21:55 math.h Dennis J. Sylvester
@ 1999-10-19 22:29 ` Arthur Gold
  1999-10-31 13:57   ` math.h Arthur Gold
  1999-10-19 23:13 ` math.h Maurizio Loreti
  1999-10-31 13:57 ` math.h Dennis J. Sylvester
  2 siblings, 1 reply; 10+ messages in thread
From: Arthur Gold @ 1999-10-19 22:29 UTC (permalink / raw)
  To: help-gcc

"Dennis J. Sylvester" wrote:
> 
> I tried using the sqrt() function with gcc and get an error : undefined
> reference to 'sqrt'.  If I compile with g++ I have no problem.  I get
> the same result when trying to use pow() also.  What am I missing?
> 
> Any help would be appreciated.
> 
> Dennis
Add the option -lm to your command line when you compile.
</rant on>
...and read the FAQs...and the docs...it's all in there...in fact if you
LOOK, this has probably been covered at least twice this week on this
and similar newsgroups...
</rant off>

HTH,
--ag
-- 
Artie Gold, Austin, TX
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
Pet peeve: "its" = belonging or pertaining to "it" | "it's" = "it is"

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

* math.h
@ 1999-10-19 21:55 Dennis J. Sylvester
  1999-10-19 22:29 ` math.h Arthur Gold
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dennis J. Sylvester @ 1999-10-19 21:55 UTC (permalink / raw)
  To: help-gcc

I tried using the sqrt() function with gcc and get an error : undefined
reference to 'sqrt'.  If I compile with g++ I have no problem.  I get
the same result when trying to use pow() also.  What am I missing?

Any help would be appreciated.

Dennis

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

end of thread, other threads:[~2005-04-05  9:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-12  9:16 math.h Tom Filley
2000-04-01  0:00 ` math.h Tom Filley
  -- strict thread matches above, loose matches on Subject: below --
2005-04-05  9:01 math.h John Poma
2005-04-05  9:21 ` math.h Leopold Palomo-Avellaneda
1999-10-19 21:55 math.h Dennis J. Sylvester
1999-10-19 22:29 ` math.h Arthur Gold
1999-10-31 13:57   ` math.h Arthur Gold
1999-10-19 23:13 ` math.h Maurizio Loreti
1999-10-31 13:57   ` math.h Maurizio Loreti
1999-10-31 13:57 ` math.h Dennis J. Sylvester

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).