Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
#include <stdio.h> #include <math.h> int main() { printf("%.81f\n", 1+2*sqrt(3)/(5-0.1)); return 0; }
输出:/tmp/a4-4oU730.o:在函数 sqrt'clang:main': a4.c:(.text+0x4f): undefined reference to错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
main': a4.c:(.text+0x4f): undefined reference to
尝试将-lmfor libm for math 添加到您的构建命令中。也就是说,您的代码在 Mac OS 上使用 clang 4.1 对我来说可以正常工作。
-lm