How to use sqrtf in gcc?
Rupert Wood
me@rupey.net
Tue Jan 29 23:55:00 GMT 2002
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.
More information about the Gcc-help
mailing list