2012-05-07 92 views
2

私はmakefileを書く初心者です。リンカー入力ファイルはリンクされていないため未使用です - gcc

PATH1 = /ref 

CC=gcc 
LINK = gcc 

INCLUDES = . 
INCLUDES += -I/PATH1/inc \ 
     -I/$(PATH1)/abc/inc/ \ 
     -I/$(PATH1)/def/inc/ 


all: src_file 

run: src_file 

src_file: 
    $(CC) $(INCLUDES) -MM /ref/abcd.c -o [email protected] 

clean: 
    rm -f *.o src_file 

私はメイクをすれば、私はエラーを取得:

linker input file unused because linking not done. 

私はstackoverflowの中にいくつかの類似の記事を読むが、解決策を得ることができなかった私はこのようなメイクファイルの何かを持っています。誰でも私のメイクファイルに何が間違っているか教えてください。前もって感謝します。

答えて

3

原因は、プリプロセッサオプション-MMです。 gcc pre-processor optionsから、

-M

Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.

Passing -M to the driver implies -E, and suppresses warnings with an implicit -w.

-MM

Like -M but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header.

だから効果的にあなただけのを前処理していないので、何のコンパイルとリンクなしと結果のエラーです。

+0

返信いただきありがとうございます。それは理にかなっている。リンクをありがとう、様々なオプションを通過します。 –

関連する問題