when I am tring to compile
#include <math.h>
#include <stdio.h>
int main()
{
double m=1.66666;
double k=sqrtf(m);
return 0;
}
using following command
/user/unicore/rs6000aix/compiler/gcc4.8.5/aix6.1/bin/gcc -o test.out test.cpp -lm
it throws
ld: 0711-317 ERROR: Undefined symbol: .sqrtf
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. collect2: error: ld returned 8 exit status
But below code compiles successfully
#include <math.h>
#include <stdio.h>
int main()
{
double k=sqrtf(1.66666);
return 0;
}
I am using gcc4.8.5 to compile the code ..same code compiles successfully on AIX6.1 but it is failing on new machine(AIX7.1)
Similar question already exist on this: Why am I getting "undefined reference to sqrt" error even though I include math.h header? but it is not working for me.
Update: when I use sqrt
instead of sqrtf
code compiles successfully, using command '/user/unicore/rs6000aix/compiler/gcc4.8.5/aix6.1/bin/gcc -o test.out test.cpp -lm to compile it.
sqrtf` fails with or without linking to math library.
edit2: output of nm command
$ nm -g -X32 /usr/lib/libm.a | grep sqrtf
.csqrtf T 512
csqrtf D 4196 12
$ nm -g -X64 /usr/lib/libm.a | grep sqrtf
.csqrtf T 512
csqrtf D 4296 24
edit 3: bos.adt.libm.7.1.3.47
was installed which doesn't have sqrtf
. Installed bos.adt.libm.7.1.4.30.bff
and it started to work fine.