c - 在 PintOS 中运行 make 时获取对 `floor' 的 undefined reference

标签 c gcc makefile

我正在尝试在 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/

相关文章:

linux - 单个主机上的多个 glibc 库

c++ - 用 C++ 打开 2 个数据文件

makefile - 使用 GNU make 的 $(foreach) 迭代一个空项目

c++ - 停止服务器->如何验证线程是否停止->pthread

c++ - 什么时候在 GCC 上的成员函数指针中使用增量?

c - sizeof 运算符的操作数

c++ - 这个makefile有什么问题

c++ - 如何生成丢失的 #include 文件列表

c - 在 while(1) 循环中阻塞的线程内处理 postthreadmessage() 或使用 "Event Driven Sockets"

c - 如何调试使用 gdb 中辅助 txt 文件输入的程序?