#include <stdio.h>
#include <math.h>
int main()
{
printf("%.81f\n", 1+2*sqrt(3)/(5-0.1));
return 0;
}
输出:
/tmp/a4-4oU730.o:功能中main':
a4.c:(.text+0x4f): undefined reference to
平方根'
clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
最佳答案
尝试将 libm for math 的 -lm
添加到构建命令中。也就是说,您的代码对我来说在 Mac OS 上使用 clang 4.1 工作得很好。
关于c - 如何使用 clang 编译带有 math.h 的 c 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16370356/