undefined reference to `sqrt' [duplicate]
问题 This question already has answers here : undefined reference to sqrt (or other mathematical functions) (5 answers) Closed 4 months ago . 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