Why Am I Getting Link Errors When Calling Function in Math.h?

前端 未结 3 1567
广开言路
广开言路 2020-12-11 06:50

When attempting to call functions in math.h, I\'m getting link errors like the following

undefined reference to sqrt

But I\'

3条回答
  •  一个人的身影
    2020-12-11 07:16

    You need to link the math library explicitly. Add -lm to the flags you're passing to gcc so that the linker knows to link libm.a

提交回复
热议问题