This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: How to use sqrtf in gcc?
- From: "Thai Dang Vu" <thaid at Cybersoft-VN dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 30 Jan 2002 17:06:58 +0700
- Subject: RE: How to use sqrtf in gcc?
Thanks for your answers. I made some mistakes in using terms. I can link
it now.
by the way, if i want to write multi-thread program on Linux, what
library should I install? I found commonc++ on GNU web site. is it the
proper library for multi_thread?
-----Original Message-----
From: Rupert Wood [mailto:me@rupey.net]
Sent: Wednesday, January 30, 2002 2:55 PM
To: Thai Dang Vu
Cc: gcc-help@gcc.gnu.org
Subject: RE: How to use sqrtf in gcc?
Thai Dang Vu wrote:
> I cannot use sqrt or sqrtf functions in gcc.
> This is my program
:
> I'm using redhat 7.2 and gcc, glibc are installed from RedHat cds.
> I can link the above program, but cannot build it. I received a
> message that there was no referrence to sqrtf on building it.
You might be confusing your terms: it's likely that you can *compile*
the program but not *link* it.
Maths functions such as sqrtf (where available) are defined in libm. You
need to add '-lm' to your command line, e.g.
gcc sqrtf-test.c -O2 -o sqrtf-test -lm
That's probably mentioned on sqrtf's man page.
As an aside, I'm not sure how portable sqrtf is - certainly, my Solaris
and Interix don't know about it but HP/UX does.
Rup.