문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top