This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]