gcc undefined reference to sqrt

When compiling GCC in Ubuntu, math. H library is not specified by default, and GCC undefined reference to sqrt appears

When this error occurs, you need to specify which library to connect to at compile time

gcc xx.c -lm -o xx.out

-L is the specified XX library, M is the math library

Similar Posts: