Answers for "undefined reference to `sqrt'"

C
1

undefined reference to `sqrt'

The math library must be linked in when building the executable.
How to do this varies by environment, but in Linux/Unix, just add
-lm to the command:

gcc test.c -o test -lm

The math library is named libm.so, and the -l command option
assumes a lib prefix and .a or .so suffix.

Credit: wallyk
Posted by: Guest on May-19-2021

Code answers related to "undefined reference to `sqrt'"

Code answers related to "C"

Browse Popular Code Answers by Language