我正在尝试在 PintOS 生成文件上运行 make,但我一直收到 undefined reference “floor”错误。生成文件如下。我正在运行带有 gcc 4.6.1 的 Ubuntu 11.10。感谢您的帮助。
all: setitimer-helper squish-pty squish-unix
CC = gcc
CFLAGS = -Wall -W
LDFLAGS = -lm
setitimer-helper: setitimer-helper.o
squish-pty: squish-pty.o
squish-unix: squish-unix.o
clean:
rm -f *.o setitimer-helper squish-pty squish-unix
~
最佳答案
-lm
应该在 LDLIBS
中,而不是 LDFLAGS
。
区别很重要,因为链接可执行文件的隐式规则是:
$(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS)
和 ld
(由 GCC 调用)具有严格的从左到右的依赖项解析算法。
关于c - 在 PintOS 中运行 make 时获取对 `floor' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9963645/