Part of my program is to calculate sqrt of float number.
When I write sqrt(1.0f); I success to compile the program,but when I write sqrt(-1.0f);
the compilation fails with undefined reference to 'sqrt' – I suppose that in this case the nan value will be returned…
I compile the program uing gcc.
When I compile it with visual studio it is compiled successfuly with negative argument to sqrt.
How the problem could be solved
Thank you
Part of my program is to calculate sqrt of float number. When I write
Share
You have to add the
-lmflag on most Unix-based systems, as in:Compile using:
and then link using:
Or if you don’t want to separate the two compilation steps, simply write: