2016-12-09 26 views
0

我遇到了C Makefile的問題。C Makefile編譯錯誤 - 「鏈接器輸入文件未使用,因爲鏈接沒有完成」

這是在bash的Makefile文件的代碼:

CC=gcc 
CFLAGS=-g -Wall 
CCLINK=$(CC) 
OBJS=flight.o runway.o airport.o main.o 
RM=rm -f 

# Creating the executable (airport) 
airport: $(OBJS) 
    $(CCLINK) -o airport $(OBJS) 

# Creating object files using default rules 
main.o: main.c airport.h ex2.h flight.h runway.h 
airport.o: airport.c airport.h ex2.h flight.h runway.h 
runway.o: runway.c runway.h ex2.h flight.h 
flight.o: flight.c flight.h ex2.h 

# Cleaning old files before new make 
clean: 
    $(RM) airport *.o *.bak *~ "#"* core 

當我把文件,上面說:

make: `airport` is up to date. 

之後 - 我稱之爲 「飛機場」,在bash和它讓我以我想要的方式輸入一些輸入。當我試圖檢查「機場」是由編譯

丁:

gcc -g -Wall -c airport 

我得到一個錯誤說:

gcc: airport: linker input file unused because linking not done 

是否有人知道可能是什麼問題?

謝謝! Gavriel。

+2

你是什麼意思*當我試圖檢查是否「機場」編譯:*? – 2501

+2

嗯,它接縫你試圖編譯你的可執行文件... – Garf365

+0

是的,嘗試'gcc -g -Wall -c airport.c'與**。c **另外,當你發出'gcc'命令,根本不使用makefile *。所以這個問題實際上可能不是關於make。但是我們都在某個時候開始學習這些東西。 * make */* gcc */* ld *之間有區別。祝你好運! :) –

回答

1

Makefile的目的是避免重新編譯文件,如果其源不變;當它發生時,make表示該文件是最新的。

如果您想再次檢查警告,這可能很煩人。然後,只需撥打make重新編譯的一切,通過鍵入

make clean ; make 

Makefile另一個目標是避免自己鍵入命令gcc,容易出錯。例如,在問題結束時,您要求從可執行文件(選項-c)製作目標文件,這是錯誤的。使目標文件的好方法是調用make

make airport.o 

最後,產生可執行文件,您可以鍵入

make airport 

,或者因爲airport:是第一目標,類型

make 
相關問題