I am having a hard time getting Ubuntu's gcc to understand the long double-manipulating functions from math.h, namely sqrtl, cabsl and cexpl. The message I get for all of them when compiling is

undefined reference to `sqrtl'

Is there any flag other than -lm that I have to put on the command line for gcc to understand these functions? Is it a missing package? Or is this a problem with the version I'm using (4.6.1 on Oneiric)?

Do you have libc6-dev? All I can say is this works here: #include <math.h> \n int main() { sqrtl(1); } .. cc test.c -o test - I don't even need -lm, it figures it out.
–
CaesiumNov 30 '11 at 15:02

Yes, I have it. And the result is the same whether I use -lm or not.
–
Sir WhiteoutNov 30 '11 at 15:34

I just tested the above code and tweaked it while trying to pinpoint the problem. It indeed works in the original form, but if I declare a long double x; variable and assign a value to it, then call sqrtl (x); the problem I reported appears.
–
Sir WhiteoutDec 1 '11 at 14:13

That's not a new requirement, although I'm willing to believe some toolchain versions had a bug that hid it. Link order has always been critical, and has always been a source of user confusion.
–
amsDec 7 '11 at 9:21