今天在编译程序时碰到该问题:
whetstone.c:(.text+0x56c): undefined reference to `sin'
whetstone.c:(.text+0x585): undefined reference to `cos'
whetstone.c:(.text+0x5cf): undefined reference to `atan'
检查头文件math.h已经包含,原来虽然程序中已经包含math.h,但在链接时要链接到数学库,加上-lm编译选项即可,如下:
将 gcc whetstone.c -o whetstone 改为 gcc whetstone.c -lm -o whetstone即可。
阅读(1208) | 评论(0) | 转发(0) |