Question

I have a problem much like the one here where the error is "Undefined reference to sqrt". I understand how using the -lm flag when compiling fixes the problem by linking it to the math library, however, are there any other possible ways to fix the problem without using any special compiler flags?

I've been happily using "-lm" while compiling my project so far, but my instructor uses try which won't accept a submission unless it compiles.... they do not use -lm.

Is there a way to solve this that doesn't require me to write my own square root function?

Was it helpful?

Solution

Other than making your own sqrt method no, though some compilers have the sqrt function already in them from what I've used so you may not need the extra flag potentially. I would email your instructor and talk to him about this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top