In said:
How to use math functions of type long double in gcc? I used powl and expl
in my source code (and included math.h) but I got "undefined reference to
`_powl'" when I tried to compile it with:
gcc -o 1_1prog 1_1prog.c -lm
I also tried "-ansi" and "-std=c99" but still got the same message. Does
anyone have any idea?
Try to engage your brain. If you're not Mark McIntyre, it usually helps.
gcc is a *compiler*. Math functions are a *library* issue, and,
therefore, their usage has precious little to do with gcc. The best you
can do at gcc invocation level is to specify -std=c99 if you need
functions that are new in C99 and hope that this will enable their
declarations in <math.h>, if such functions are present at all in your
libraries. But this has absolutely no effect on whether the linker will
or will not find them in the actual libraries. However, if you also use
-Wall, you'll know, at least, whether declarations for the functions in
question have been found in <math.h> or not (you'll get warnings for
each function that is called without a declaration in scope).
Your experiment has clearly shown that there is no such thing as powl in
your libm library. There is absolutely nothing gcc can do about this!
And, since we don't know what system and what libraries you're using,
there is no way we can provide a solution (other than advise to write
your own versions of the missing functions).
You may get better advice in a newsgroup dedicated to programming on your
platform, especially if you mention what libraries you have installed
on your machine (again: it's a library issue, not a gcc issue).
Dan