我使用ceil()执行了以下代码
#include<stdio.h>
#include<math.h>
int main()
{
float val;
float cVal;
val=23.4;
cVal =ceil(val);
printf("ceil value:%f\n",cVal);
return 0;
}我在函数main': test1.c:(.text+0x1b): undefined reference toceil‘collect2中遇到以下错误: error: ld returned 1 exit status
这段代码出了什么问题??请帮帮忙!
我是用makefile编译的
>>cmake .
>>make
>>./hello.out发布于 2020-02-18 13:23:44
来自https://askubuntu.com/a/745199/513302
如果要使用
gcc在Linux中使用math.h库编译C程序,则必须在编译器命令行中使用–lm选项
gcc xyz.c -o xyz -lm-lm选项实际上是-l (代表"link a module"),而m是内置数学库的缩写。
https://stackoverflow.com/questions/60274177
复制相似问题