GCC链接器问题与-lm标志

Tyl*_*eat 0 c linker gcc makefile

我遇到了GCC链接器的问题,特别是使用了-lm标志,因为我正在使用math.h中的一些函数.我收到以下错误:

main.c :(.text + 0x8e5):未定义引用`floor'

main.c :(.text + 0x901):未定义的引用`ceil'

这是我的makefile的相关部分:

myprogram: main.o
    gcc -Wall -pedantic -o myprogram main.o

main.o: main.c foo.h bar.h
    gcc -Wall -pedantic -lm main.c
Run Code Online (Sandbox Code Playgroud)

我可能会忽略一些愚蠢的东西,但在制作文件方面,我绝对不是专家.

use*_*775 5

此外,库规范必须在引用它们的对象之后(参见错误位置的链接器标志).