2012-04-01 156 views
3

我試圖在PintOS makefile上運行make,但是我不斷收到對'floor'錯誤的未定義引用。下面是makefile。我使用gcc 4.6.1運行Ubuntu 11.10。任何幫助表示讚賞。在PintOS上運行時獲取對「floor」的未定義引用

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 

+0

Make將打印它正在調用的確切命令。 GCC運行的確切命令是什麼? – 2012-04-01 12:07:14

+0

可能庫在對象文件和鏈接器處於按需模式之前傳遞。嘗試使用'gcc -o something something.o -lm',或者將'-Wl, - 不需要的'添加到編譯器標誌。 – 2012-04-01 12:07:57

回答

8

-lm應該在LDLIBS,不LDFLAGS

的區別是很重要的,因爲用於連接可執行文件的隱含規則是:

$(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS) 

ld(GCC所調用的)有嚴格的左到右依賴解析算法。

相關問題